Mean and Std in Subplot Graphs

2 vues (au cours des 30 derniers jours)
Sérgio Querido
Sérgio Querido le 17 Sep 2017
Commenté : Star Strider le 17 Sep 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''')

Réponses (1)

Star Strider
Star Strider le 17 Sep 2017
Modifié(e) : Star Strider le 17 Sep 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 commentaires
Sérgio Querido
Sérgio Querido le 17 Sep 2017
The code is ok to mean and std lines. But, how can i put y variable in that code??
Star Strider
Star Strider le 17 Sep 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.

Connectez-vous pour commenter.

Catégories

En savoir plus sur 2-D and 3-D Plots dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by