Display results from t-test after loop

조회 수: 4 (최근 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

카테고리

Help CenterFile Exchange에서 MATLAB에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by