Adding sentences with calculated numbers to a plot

I want to add 3 sentences with a calculated numbers underneath a plot. I tried using a second line in the x-label, which works, but it doesn't calculate the number. Is this even possible?

2 件のコメント

madhan ravi
madhan ravi 2018 年 9 月 5 日
can you describe by pasting your code and what's your desired output?
jonas
jonas 2018 年 9 月 5 日
What do you mean?? Perhaps you are looking to put the content of a numerical variable in a string? If so, then you're looking for sprintf

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

回答 (1 件)

Star Strider
Star Strider 2018 年 9 月 6 日

1 投票

Use the text (link) function.
Example
x = 1:10;
y = rand(1,10);
AB = rand(1,2);
figure
plot(x, y)
xext = get(gca, 'XLim');
yext = get(gca, 'YLim');
text(1.4*xext(1), yext(1)-0.1*diff(yext), sprintf('The value of A is %.3f\nThe value of B is %.3f', AB))
Experiment to get the result you want.

カテゴリ

ヘルプ センター および File ExchangeData Type Identification についてさらに検索

質問済み:

2018 年 9 月 5 日

回答済み:

2018 年 9 月 6 日

Community Treasure Hunt

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

Start Hunting!

Translated by