Converting whole numbers to scientific notation
30 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Is it possible to convert a whole number to a decimal and then later to scientific notation? For example, I would like to have '0' in the following format: 0.0000e+00. I've tried using the "format short e" and "format long e" commands but they are not working.
0 comentarios
Respuestas (3)
Walter Roberson
el 15 de Jun. de 2022
Not with the default display routines, no. You can use sprintf() or compose() with %.4e format to get character vector or string() objects
0 comentarios
Star Strider
el 16 de Jun. de 2022
Another option —
expstr = @(x) [x(:).*10.^ceil(-log10(abs(x(:)+(x==0)))) floor(log10(abs(x(:)+(x==0))))]; % Updated: 2021 05 04
n = 0;
Result = sprintf('%.4fe%+04d', expstr(n))
Result = sprintf('%.4fe%+03d', expstr(n))
.
0 comentarios
Ver también
Categorías
Más información sobre Data Type Conversion en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!