필터 지우기
필터 지우기

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

조회 수: 9 (최근 30일)
Jaclyn
Jaclyn 2013년 9월 1일
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에서 Logical에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by