Desktop Tools and Development Environment Previous page   Next Page

Formatting and Spacing Numeric Output

By default, numeric output in the Command Window is displayed as 5-digit scaled, fixed-point values, called the short format. To change the numeric format of output for the current and future sessions, set the Command Window preference for text display. The text display format affects only how numbers are shown, not how MATLAB computes or saves them.

Function Alternative

Use the format function to control the output format of the numeric values displayed in the Command Window. The format you specify applies until you change it or until the end of the session. More advanced alternatives are listed in the "See Also" section of the format reference page.

Examples of Formats

Here are a few examples of the various formats and the output produced from the following two-element vector x.

x = [4/3 1.2345e-6]

format short
   1.3333    0.0000

format short e
   1.3333e+000  1.2345e-006

format + 
++

A complete list and description of available formats is in the reference page for format. For more control over the output format, use the sprintf and fprintf functions.

Controlling Spacing

To control spacing in the output, use the Command Window preference for text display or the format function. Use

format compact

to suppress blank lines, allowing you to view more information in the Command Window. To include the blank lines, which can help make output more readable, use

format loose

Previous page  Controlling Output Clearing the Command Window Next page

© 1994-2005 The MathWorks, Inc.