Mean and Std in Subplot Graphs

2 visualizaciones (últimos 30 días)
Sérgio Querido
Sérgio Querido el 17 de Sept. de 2017
Comentada: Star Strider el 17 de Sept. de 2017
How can i add mean and Std horizontal lines to all plots?? (eg.ym1 and ys1 are mean and std of subplot subplot(3, 2, 1))
figure
subplot(3, 2, 1)
ym1=mean(distlocus1)
ys1=std(distlocus1)
plot(distlocus1)
title('Início - 15''')
subplot(3, 2, 2)
ym2=mean(distlocus2)
ys2=std(distlocus2)
plot(distlocus2)
title('15'' - 30''')
subplot(3, 2, 3)
ym3=mean(distlocus3)
ys3=std(distlocus3)
plot(distlocus3)
title('30'' - Intervalo''')
subplot(3, 2, 4)
ym4=mean(distlocus4)
ys4=std(distlocus4)
plot(distlocus4)
title('Intervalo'' - 60''')
subplot(3, 2, 5)
ym5=mean(distlocus5)
ys5=std(distlocus5)
plot(distlocus5)
title('60'' - 75''')
subplot(3, 2, 6)
ym6=mean(distlocus6)
ys6=std(distlocus6)
plot(distlocus6*ym6)
title('75'' - Final''')

Respuestas (1)

Star Strider
Star Strider el 17 de Sept. de 2017
Editada: Star Strider el 17 de Sept. de 2017
I would plot them as:
plot(xlim, [1 1]*ym1, '-r', xlim, ym1+[1 -1; 1 -1]*ys1, '-g')
and so for the others.
This plots the mean in red, and the the two standard deviation lines in green. This uses xlim, so it will automatically span the x-axis limits.
  2 comentarios
Sérgio Querido
Sérgio Querido el 17 de Sept. de 2017
The code is ok to mean and std lines. But, how can i put y variable in that code??
Star Strider
Star Strider el 17 de Sept. de 2017
I was thinking of something like this:
subplot(3, 2, 1)
ym1=mean(distlocus1)
ys1=std(distlocus1)
plot(distlocus1)
hold on
plot(xlim, [1 1]*ym1, '-r', xlim, ym1+[1 -1; 1 -1]*ys1, '-g')
hold off
title('Início - 15''')
So add the hold calls, and the new plot call, to plot the mean and standard deviation. This applies to all the subplots, so all you need to do is to change ‘ym1’ and ‘ys1’ in the other subplots to their appropriate variables.

Iniciar sesión para comentar.

Categorías

Más información sobre 2-D and 3-D Plots en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by