MATLAB Programming Fundamentals - MathWorks

(やまだぃちぅ) #1

Display Format for Numeric Values


In this section...
“Default Display” on page 4-22
“Display Format Examples” on page 4-22
“Setting Numeric Format in a Program” on page 4-23

Default Display


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:


  • 5-digit scaled fixed point, floating point, or the best of the two

  • 15-digit scaled fixed point, floating point, or the best of the two

  • A ratio of small integers

  • Hexadecimal (base 16)

  • Bank notation


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:

get(0, 'format')
ans =
short

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

4 Numeric Classes

Free download pdf