Borrar filtros
Borrar filtros

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

9 visualizaciones (últimos 30 días)
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.

Respuesta aceptada

the cyclist
the cyclist el 1 de Sept. de 2013
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 comentarios
the cyclist
the cyclist el 1 de Sept. de 2013
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 el 1 de Sept. de 2013
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!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Logical en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by