Perform student t-test on 3D matrix (on each grid point)

9 次查看(过去 30 天)
Hi I have a 3D matrix (x,y,z) and I need to perform a t-test at each grid point (x,y) to test if the mean of the values in the z direction is significantly higher than zero.
My attempt:
A=data(306,6,63); %data
for x=1:306
for y=1:6
h(x,y)=ttest(A(x,y,:),'Alpha',0.01,'Tail','right'):
end
end
I wasn't sure how to handle the z direction in the loop. I've played around this this a lot getting various errors, right now it says "The data in a paired t-test must be the same size". I want to do a one-sample test on each grid point to get a 2D output indicating which grid points are significantly different.

采纳的回答

the cyclist
the cyclist 2013-9-1
It's just a minor syntax error. Try
h(x,y)=ttest(A(x,y,:),[],'Alpha',0.01,'Tail','right');
Notice that I put in an empty array for the second argument.
(This was not particularly clear, in my opinion, from the documentation.)
  3 个评论
the cyclist
the cyclist 2013-9-1
Since I did not have your data, this is the code I ran:
A = randn(306,6,63);
for x=1:306
for y=1:6
h(x,y)=ttest(A(x,y,:),[],'Alpha',0.01,'Tail','right');
end
end
Does that work for you?
If not, it could be a versioning issue. I have R2013a on Mac OS X 10.8.4.
Jaclyn
Jaclyn 2013-9-1
Ah yes that's probably the issue! Never thought of that, I have 2011. I just looked up the old documentation and I got this to work:
for x=1:306
for y=1:6
h(x,y)=ttest(A(x,y,:),0,0.01,'right');
end
end
Thanks for your help!

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by