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!