How to change e format?
Afficher commentaires plus anciens
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 commentaires
x = [0.00005; 0.0002; 1.00; 0.0015; 0.02; 0.01;];
txt = sprintf('[%.0e; %.4f; %.2f; %.4f; %.2f; %.2f]',x)
hyein Sim
le 19 Mar 2021
Walter Roberson
le 19 Mar 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
le 19 Mar 2021
Walter Roberson
le 19 Mar 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
le 19 Mar 2021
Rik
le 19 Mar 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
le 21 Mar 2021
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Logical dans Centre d'aide et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!