Programming Previous page   Next Page

Display Format for Numeric Values

By default, MATLAB displays numeric output as 5-digit scaled, fixed-point values. You can change the way numeric values are displayed to any of the following:

All available formats are listed on the format reference page.

To change the numeric display setting, use either the format function or the Preferences dialog box (accessible from the MATLAB File menu). The format function changes the display of numeric values for the duration of a single MATLAB session, while your Preferences settings remain active from one session to the next. These settings affect only how numbers are displayed, not how MATLAB computes or saves them.

Display Format Examples

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

Check the current format setting:

Set the value for x and display in 5-digit scaled fixed point:

Set the format to 5-digit floating point:

Set the format to 15-digit scaled fixed point:

Set the format to 'rational' for small integer ratio output:

Set an integer value for x and display it in hexadecimal (base 16) format:

Setting Numeric Format in a Program

To temporarily change the numeric format inside a program, get the original format using the get function and save it in a variable. When you finish working with the new format, you can restore the original format setting using the set function as shown here:

Previous page  Identifying Numeric Types Function Summary Next page

© 1994-2005 The MathWorks, Inc.