how to write numbers with 10^ format in matlab?
32 ビュー (過去 30 日間)
古いコメントを表示
How to print 123456 as 1.2x10^5 in a matlab figure?
str5 = ['CC = ' num2str(123456) ];
str = sprintf('%s',str5);
annotation('textbox',[0.1 0.1 0.1 0.1],'String',str,'FitBoxToText','on');
Any help will be greatly appriciated.
0 件のコメント
採用された回答
Stephen23
2022 年 8 月 10 日
編集済み: Stephen23
2022 年 8 月 10 日
str = strrep(sprintf('CC = %.1e',123456),'e','x10^')
str = regexprep(sprintf('CC = %.1e',123456),'e(\D)0*(\d+)$','x10^$1$2')
4 件のコメント
Stephen23
2022 年 8 月 10 日
編集済み: Stephen23
2022 年 8 月 10 日
"Why does that appear like this"
This is due to how the graphics engine interprets text. You need to either:
- set the text interpreter to "none" (rather than using the default "tex"), or
- create valid tex/latex markup for the caret character (and any other special characters): https://tex.stackexchange.com/questions/77646/how-to-typeset-the-symbol-caret-circumflex-hat
str = strrep(sprintf('CC = %.1e',123456),'e','x10^')
plot(0:1,0:1)
annotation('textbox',[0.5,0.5,0.1,0.1],'String',str,'interpreter','none')
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Interactive Control and Callbacks についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!