Set output display format for Command Window
format( changes the output
display format in the Command Window to the format specified by
style)style. For example, format("shortG")
displays numeric values in a compact form with 5 total digits. Numeric formats
affect only how numbers appear in Command Window output, not how MATLAB® computes or saves them.
When you specify the style by name, you can use command form without parentheses or quotes:
format shortG
stores the current display format in fmt = format(style)fmt and then changes
the display format to the specified style. (since
R2021a)
You cannot use command form when you request output or when you pass a variable as input. Enclose inputs in parentheses and include style names in quotes.
fmt = format("shortG");
format(fmt)The specified format applies only to the current MATLAB session. To maintain a format across sessions, choose a Numeric format or Line spacing option in the Command Window preferences.
You can specify short or long and the
presentation type separately, such as format short E or
format("short E").
MATLAB always displays integer data types to
the appropriate number of digits for the data type. For example, MATLAB uses
3 digits to display int8 data types (for instance,
-128:127). Setting the output format to short or long does
not affect the display of integer-type variables.
Integer-valued, floating-point numbers with a maximum of 9 digits do not display in scientific notation.
If you are displaying a matrix with a wide range of
values, consider using shortG. See Large Data Range Format.