how to display figures on a plot

2 ビュー (過去 30 日間)
Postit123
Postit123 2020 年 11 月 19 日
コメント済み: Postit123 2020 年 11 月 19 日
Hello
I want to display mean and std with some text in a text box on a plot.
For now, I don't know how to relate the values, so I just write the code like this.
I put values one by one after calculating mean and std.
is there any way to take values automatically to the annotation?
Thank you in advance.
[xyz, mn, st] = nmea(stop);
% mn = mean
% st = std
plot(1:length(stop),xyz);
xlabel('time [sec]');
ylabel('position [m]')
legend('x','y','z');
str = {'mean_x = -3035497.2060m';'mean_y = 4047836.2866m';'mean_z = 3896386.6521m';'std_x = 1.7452m'; 'std_y = 1.1734m'; 'std_z = 1.9720m'};
dim = [0.53 0.27 .2 .2];
annotation('textbox',dim,'String',str,'FitBoxToText','on');

採用された回答

Alan Stevens
Alan Stevens 2020 年 11 月 19 日
str = {['mean_x = ',num2str(mean(x))],...etc}
for example.
Type: doc num2str in the command window.
  2 件のコメント
Rik
Rik 2020 年 11 月 19 日
I personally prefer sprintf, because it allows you more control and is trivial to adapt to write content to a file instead.
Postit123
Postit123 2020 年 11 月 19 日
Thank you! I've tried both and successfully displayed mean and std.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeConvert Image Type についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by