Integrating a t-test into a function how-to

4 visualizaciones (últimos 30 días)
Mau Dudas
Mau Dudas el 27 de Nov. de 2019
Respondida: Jeff Miller el 28 de Nov. de 2019
Hey, I need to run two t-tests on my dataset in a fucntion one is meant to compare the means of reaction times and the other has to compare the two variances between
coefficient values (std/means).
The ttest function works fine until I try and integrate it into a function.
This is what I have so far but it seems to come up with the error message undefined variable 'x' or undefined variable 'y'
I've tried renaming the means as 'c1m' but it keeps swithcing them out for '1cm'
function [h,p] = suffer3(data,x,y)
files = dir(data);
for s = 1:size(files,1)
temp = load(file(s).name;
tempdata = temp.data.reproduction;
x = mean (tempdata(tempdata (:,1)==1,2))
y = mean (tempdata(tempdata(:,1)==0,2))
[h,p]= ttest2(x, y)
end
Both my 'h' & 'p' outputs say NaN when i run the function.
Little help as to what I'm doing wrong would be grandly appreciated :)

Respuestas (1)

Jeff Miller
Jeff Miller el 28 de Nov. de 2019
Put in a breakpoint at the ttest2 line and check the inputs x and y that you are passing. These must not be what ttest2 expects.

Categorías

Más información sobre Hypothesis Tests 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