Display results from t-test after loop

2 Ansichten (letzte 30 Tage)
RP
RP am 16 Apr. 2019
Beantwortet: KSSV am 16 Apr. 2019
I have a loop running through participants 1-10 in which (among other thigns) two t-tests are conducted for each participant. I would like to have the results for each participant to be displayed in the end after the loop is done, ideally in a table but I don't know if that is at all possible, but it would be alright to just have the two p-values for each participant displayed. I tried to create a structure which looks like this but I get the error message "Subscript indices must either be real positive integers or logicals". How can I fix this?
for subject = 1:10
for phase = 1:3
[h, p, ci, stats] = ttest(CSplus_A, CSminus)
p_value_A.(sprintf('s%d_%d', subject, phase)) = p
[h, p, ci, stats] = ttest(CSplus_B, CSminus)
p_value_B.(sprintf('s%d_%d', subject, phase)) = p
end
end

Antworten (1)

KSSV
KSSV am 16 Apr. 2019
YOu can make them a matrix...why structure?
p_value_A = zeros(10,3) ;
p_value_B = zeros(10,3) ;
for subject = 1:10
for phase = 1:3
[h, p, ci, stats] = ttest(CSplus_A, CSminus)
p_value_A(subject, phase) = p ;
[h, p, ci, stats] = ttest(CSplus_B, CSminus)
p_value_B(subject, phase) = p ;
end
end

Kategorien

Mehr zu Mathematics and Optimization finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by