How to change e format?
古いコメントを表示
I want to change the number's format.
I written
x=[0.00005; 0.0002; 1.00; 0.0015; 0.02; 0.01;];
txt=sprintf('%.e %.4f %.2f %.4f %.2f %.2f',x);
and the result is txt
5.e-05 0.0002 1.00 0.0015 0.02 0.01
But I want to change
x=[0.00005; 0.0002; 1.00; 0.0015; 0.02; 0.01;];
to
x=[5E-005; 0.0002; 1.00; 0.0015; 0.02; 0.01;];
What can I do for this?
Plz help me... ;(
9 件のコメント
x = [0.00005; 0.0002; 1.00; 0.0015; 0.02; 0.01;];
txt = sprintf('[%.0e; %.4f; %.2f; %.4f; %.2f; %.2f]',x)
hyein Sim
2021 年 3 月 19 日
Walter Roberson
2021 年 3 月 19 日
What is the purpose of doing that?
What are the rules involved? absolute value less than 1e-4 is to be converted to single digit scientific? Absolute value 1e-4 up to (excluding) 1e-2 is to use 4 digit fixed format? Absolute value 1e-2 (inclusive) to (something?) is to use 2 digit fixed format?
hyein Sim
2021 年 3 月 19 日
Walter Roberson
2021 年 3 月 19 日
We need rules. How many digits after the decimal place, under what circumstances?
For example how should 0.000314159265358979308997711132889207874541170895099639892578125 be output? How should pi/10000 be output? How should 70, 7, 1/7, 1/70, 1/700, 1/7000 be output ?
hyein Sim
2021 年 3 月 19 日
Rik
2021 年 3 月 19 日
So you just want to format the exponent with 3 digits instead of 2? (And use '%.4f' for values larger than 5e-5)
hyein Sim
2021 年 3 月 21 日
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Logical についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!