How to make a loop to average the values?
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Hyeonjun Park
el 2 de Jul. de 2021
Comentada: Hyeonjun Park
el 2 de Jul. de 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 comentarios
Respuesta aceptada
Yazan
el 2 de Jul. de 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 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Loops and Conditional Statements en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!