How to print some numeric value by using xlabel in subplot?

5 ビュー (過去 30 日間)
sami ullah
sami ullah 2020 年 11 月 28 日
回答済み: Image Analyst 2020 年 11 月 28 日
I have following code:
figure
NC = 0.79 % May be any value returned from some function.
subplot(3,4,);
imshow(extracted_watermark);
xlabel([attack 'NC='+char(NC)]);
Here Xlabel is giving output like this (NC= )
It shuld give output numeric value of NC like this (NC=0.79).

採用された回答

Image Analyst
Image Analyst 2020 年 11 月 28 日
Try this
NC = 0.79 % May be any value returned from some function.
subplot(3,4,1);
imshow(extracted_watermark);
caption = sprintf('NC=%.2f', NC); % Add in attack if you want
xlabel(caption, 'FontSize', 20); % I have no idea what "attack" is.

その他の回答 (1 件)

dpb
dpb 2020 年 11 月 28 日
xlabel(num2str(NC,'NC=%.2f'))
Dunno what "attack" above represents. If it's a char variable and wanted as part of the string, then include as desired in the format string.
See Also
compose, sprintf
and the section on annotation of graphics for many examples...

カテゴリ

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

タグ

製品


リリース

R2015a

Community Treasure Hunt

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

Start Hunting!

Translated by