keep scientific notation in plot title

20 ビュー (過去 30 日間)
Lorenzo Mattera
Lorenzo Mattera 2020 年 5 月 24 日
コメント済み: Rik 2020 年 5 月 24 日
I have a variable in scientific notation as
a=1.2310^-3
if I use
b=string(a)
to add b to a plot title
I get in the title
0.000123
any way to avoid this and keep in the title 1.23^-3 ???
Thanks
Renzo

回答 (1 件)

Rik
Rik 2020 年 5 月 24 日
If you want a specific notation you can enforce that with the sprintf function. Otherwise Matlab will automagically pick a format for you.
  2 件のコメント
Lorenzo Mattera
Lorenzo Mattera 2020 年 5 月 24 日
Thank you for your time and to draw my attention to the format issue
Actually I realized that my problem was due to the use of the string function
I had
a=1.234^-3
and using
b= string(a)
I got in the title 0.0001234
Instead of string if I use num2str
b=num2str(a,'%10.3e')
in the title appears correctly
1.234e-03
Thank you again
Renzo
Rik
Rik 2020 年 5 月 24 日
In this situation num2str will do the trick, but in the future you would probably need to look into the sprintf function.

サインインしてコメントする。

カテゴリ

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

タグ

製品


リリース

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by