How to display a number in a scientific notation in the plot?

조회 수: 13 (최근 30일)
Vikash Pandey
Vikash Pandey 2022년 1월 14일
댓글: Vikash Pandey 2022년 1월 16일
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
Walter Roberson
Walter Roberson 2022년 1월 14일
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.

댓글을 달려면 로그인하십시오.

답변 (1개)

Robert U
Robert U 2022년 1월 14일
Hi Vikash Pandey,
have a look at the function num2eng from Mathworks File Exchange. You can change easily the tick label:
fh = figure;
ah = axes(fh);
ph = plot(ah,1000:1000:10000,0:1000:9000)
ah.XTickLabel = num2eng(ah.XTick)
ah.YTickLabel = num2eng(ah.YTick)
Kind regards,
Robert
  댓글 수: 1
Vikash Pandey
Vikash Pandey 2022년 1월 14일
@Robert U Thanks for your efforts, but it seems you misunderstood the question.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Annotations에 대해 자세히 알아보기

태그

제품


릴리스

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by