'How to conduct t-test for groups of a range of x-values in MATLAB?

here is my full code

Here is a plot of the data I want to do a t-test on.

I want to do a t-test on bins of multiple eccentricities rather than the mean of the black and red lines. For an example, I want to do a t-test on the eccentricity range 0-2, then 2-4 etc.,

For the mean of the oblique and cardinal directions I was able to do this:

%% grouped data
cardinal = [mean(outMatrix(:,[ 5]),2);mean(outMatrix(:,[3 7]),2)];

horizontal = reshape(outMatrix(:,[1 5]),numel(outMatrix(:,[1 5])),1);
vertical = reshape(outMatrix(:,[3 7]),numel(outMatrix(:,[3 7])),1);
oblique = [mean(outMatrix(:,[2 4]),2);mean(outMatrix(:,[6 8]),2)];
%% t-tests: cardinal vs oblique 
ttest(cardinal,oblique) % = 0

[h p ci tstats] = ttest(cardinal-oblique);
% h = 0; t(19) = -0.9385, p=0.3598


ttest(vertical,oblique) % = 1
ttest(horizontal,oblique) % = 0


[h p ci tstats] = ttest(vertical-oblique)

% h =1; --> reject the null hypothesis
% t(19) = -3.9643 , p<= 0.001



[h p ci tstats] = ttest(horizontal-oblique)
% h = 0; t(19) = -0.0127, p = 0.99 (no significant difference)



[h p ci tstats] = ttest(vertical-horizontal)

%h = 1; t(19) = -3.7235, p = 0.0014 (p<0.005)

But I do not know how to modify it such that I do it on bins of eccentricity.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source