Mean and Std in Subplot Graphs

6 ビュー (過去 30 日間)
Sérgio Querido
Sérgio Querido 2017 年 9 月 17 日
コメント済み: Star Strider 2017 年 9 月 17 日
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''')

回答 (1 件)

Star Strider
Star Strider 2017 年 9 月 17 日
編集済み: Star Strider 2017 年 9 月 17 日
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 件のコメント
Sérgio Querido
Sérgio Querido 2017 年 9 月 17 日
The code is ok to mean and std lines. But, how can i put y variable in that code??
Star Strider
Star Strider 2017 年 9 月 17 日
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.

サインインしてコメントする。

カテゴリ

Help Center および File Exchange2-D and 3-D Plots についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by