Print number as .0000000E+00

11 visualizaciones (últimos 30 días)
Hamilton
Hamilton el 18 de Jun. de 2013
I would like to print a number with the following format:
.0000000E+00
MATLAB prefers the following:
0.0000000E+000
Is there a way to solve this issue?

Respuesta aceptada

Jan
Jan el 18 de Jun. de 2013
  2 comentarios
Hamilton
Hamilton el 19 de Jun. de 2013
This is helpful removing the leading zero. Is there a way to maintain the exponential format? I think i can take care of the E+000 to E+00 issue by simply using some string modification functions.
Jan
Jan el 19 de Jun. de 2013
Perhaps something like this:
char(java.text.DecimalFormat('#,##0.###E00').format(0.1));

Iniciar sesión para comentar.

Más respuestas (1)

Pourya Alinezhad
Pourya Alinezhad el 18 de Jun. de 2013
fprintf('%1.5s',0.1)
1.5 stands for 5 decimal places.1 is for full number.
s==scientific
you could easily find a way to this problem if you were a c proogrammer...
  3 comentarios
Pourya Alinezhad
Pourya Alinezhad el 18 de Jun. de 2013
actually i didn't checked this code in matlab.i used to code in this way in turbo c.and i per-assumed that this is true in matlab :)
Jan
Jan el 19 de Jun. de 2013
@Pourya: And obviously your assumption is not really wrong. Thanks for this interesting new piece of information.
Of course TMW did not implement fprintf from scratch but relies on existing libraries. Therefore even known bugs like buffer overflows and other undocumented features like %s with numbers appear in Matlab.

Iniciar sesión para comentar.

Categorías

Más información sobre Language Fundamentals 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!

Translated by