How can I introduce a variable in a plot using text?

16 ビュー (過去 30 日間)
L
L 2018 年 7 月 11 日
コメント済み: L 2018 年 7 月 12 日
Hello,
I am trying to make some text appear to the right of my plot and in that text there is a variable that changes depending on the numbers.
For example:
x = 1:0.5:5;
y = 5;
m = 15.35;
plot(x,y*ones(size(x)),'r','LineWidth',2)
text(5,5,'\leftarrow' num2str(m)'s','r','FontSize',10);
But it isn't working. I want the text to appear to the right of the horizontal line. I've looked up and down the internet but can't seem to find out how to do this for text.
Thank you!

採用された回答

dpb
dpb 2018 年 7 月 11 日
Need to fix the syntax errors, first in the string and then in text...
text(5,5,['\leftarrow' num2str(m)],'color','r','FontSize',10);
You might also check out
doc annotation
  1 件のコメント
L
L 2018 年 7 月 12 日
Thank you dpb! I also appreciate the referral to the annotation documentation.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeAnnotations についてさらに検索

製品


リリース

R2016b

Community Treasure Hunt

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

Start Hunting!

Translated by