How do I insert a variable value in legend of a plot?
154 ビュー (過去 30 日間)
古いコメントを表示
I have a varible p, with a value -2.2. How do I insert this value in the legend function, for a plot?
eg.- legend('Value 1=p'); % I wish to have the numeric value of p (2.2) in place of 'p'.
0 件のコメント
採用された回答
Murugan C
2021 年 9 月 6 日
use below code
value_x = 2.2;
value_y = 2.5;
legend(sprintf('Value-X = %g',value_x),sprintf('Value-Y = %g',value_y))
その他の回答 (1 件)
DGM
2021 年 9 月 6 日
There are a bunch of examples around. The sidebar shows some. Here are some others:
参考
カテゴリ
Help Center および File Exchange で Legend についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!