How to display a number in a scientific notation in the plot?
古いコメントを表示
The code is below:
n=1000;
text(0.82,0.96, "$N =\mbox{ } $" +num2str(n), 'interpreter', 'latex', 'FontSize', 38) ;
I want that, "N =10^3" be displayed and not "N = 1000".
8 件のコメント
Rik
2022 年 1 月 14 日
Only the first and last line are relevant.
What did you attempt? And is n guaranteed to be a power of 10?
It is probably easiest to use the sprintf function and edit that output.
Vikash Pandey
2022 年 1 月 14 日
Walter Roberson
2022 年 1 月 14 日
text(0.82,0.96, sprintf("$N =\\mbox{10^{%d}}$", log10(n)), 'interpreter', 'latex', 'FontSize', 38) ;
Vikash Pandey
2022 年 1 月 14 日
Vikash Pandey
2022 年 1 月 14 日
That is exactly the result of the code that Walter provided:
n=1000;
sprintf("$N =\\mbox{10^{%d}}$", log10(n))
The problem is your \mbox .
n = 1000;
text(0.82,0.96, sprintf("$N ={10}^{%d}$", log10(n)), 'interpreter', 'latex', 'FontSize', 18) ;
The support TeX markup is shown at https://www.mathworks.com/help/matlab/ref/matlab.graphics.primitive.text-properties.html#budt_bq-1_sep_shared-Interpreter . Unfortunately I do not see a list of supported latex markup.
Vikash Pandey
2022 年 1 月 16 日
回答 (1 件)
カテゴリ
ヘルプ センター および File Exchange で Annotations についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
