Format short - how does it work?

1 visualización (últimos 30 días)
SP
SP el 20 de Jul. de 2016
Editada: Stephen23 el 22 de Jul. de 2016
format short;
A = 12.3456789
B = 1234.56789
Output is:
A = 12.3457
B = 1.2346e+03
Why is output A not "1.2345e+01"? What does format "short" do?

Respuesta aceptada

dpb
dpb el 20 de Jul. de 2016
Per the "Algorithms" notes in the doc, "If the largest element of a matrix is larger than 103 or smaller than 10-3, then MATLAB applies a common scale factor for the short and long format."
I hadn't really tested before, I thought it was a %g format but it doesn't actually follow those rules which count the number of significant digits to be shown. It's internal as above says purely only magnitude of exponent >3
  2 comentarios
SP
SP el 22 de Jul. de 2016
btw where do yo find the "Algorithms" notes?
Stephen23
Stephen23 el 22 de Jul. de 2016
Editada: Stephen23 el 22 de Jul. de 2016
@SP: open the MATLAB help for format (not online, the actual MATLAB help). Scroll to the very bottom. Look for the heading "More About": click the "> Algorithms" text.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Entering Commands en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by