How to change e format?
Mostrar comentarios más antiguos
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 comentarios
x = [0.00005; 0.0002; 1.00; 0.0015; 0.02; 0.01;];
txt = sprintf('[%.0e; %.4f; %.2f; %.4f; %.2f; %.2f]',x)
hyein Sim
el 19 de Mzo. de 2021
Walter Roberson
el 19 de Mzo. de 2021
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
el 19 de Mzo. de 2021
Walter Roberson
el 19 de Mzo. de 2021
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
el 19 de Mzo. de 2021
Rik
el 19 de Mzo. de 2021
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
el 21 de Mzo. de 2021
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Logical en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!