How to make a loop to average the values?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Hyeonjun Park
am 2 Jul. 2021
Kommentiert: Hyeonjun Park
am 2 Jul. 2021
Hi guys,
I have written
BV_14_L_mean = mean(BV_14_L,2);
BV_14_L_std = std(BV_14_L,0,2);
BV_16_L_mean = mean(BV_16_L,2);
BV_16_L_std = std(BV_16_L,0,2);
BV_18_L_mean = mean(BV_18_L,2);
BV_18_L_std = std(BV_18_L,0,2);
BV_20_L_mean = mean(BV_20_L,2);
BV_20_L_std = std(BV_20_L,0,2);
BV_22_L_mean = mean(BV_22_L,2);
BV_22_L_std = std(BV_22_L,0,2);
BV_L_mean_graph = errorbar(BV_14_L_mean,BV_14_L_std,'-','LineWidth',2)
view([90, -90])
hold on
errorbar(BV_16_L_mean,BV_16_L_std,'--','LineWidth',2)
view([90, -90])
hold on
and so on..
I would like to make the codes below shorter by using a for loop.
BV_14_L_mean = mean(BV_14_L,2);
BV_14_L_std = std(BV_14_L,0,2);
so on
BV_14_L to BV_22_L are 10*5 doubles.
How should I do it?
0 Kommentare
Akzeptierte Antwort
Yazan
am 2 Jul. 2021
If you want to use a for loop, you can do this
for j=14:22
eval(sprintf('BV_%g_L_mean = mean(BV_%g_L,2);', j, j));
eval(sprintf('BV_%g_L_std = std(BV_%g_L,0,2);', j, j));
end
3 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Loops and Conditional Statements 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!