Display results from t-test after loop

5 ビュー (過去 30 日間)
RP
RP 2019 年 4 月 16 日
回答済み: KSSV 2019 年 4 月 16 日
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

回答 (1 件)

KSSV
KSSV 2019 年 4 月 16 日
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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by