Clear Filters
Clear Filters

Display results from t-test after loop

3 views (last 30 days)
RP
RP on 16 Apr 2019
Answered: KSSV on 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

Answers (1)

KSSV
KSSV on 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

Categories

Find more on Mathematics and Optimization in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!