This is machine translation

Translated by Microsoft
Mouse over text to see original. Click the button below to return to the English verison of the page.

라이선스가 부여된 사용자만 번역 문서를 볼 수 있습니다. 번역 문서를 보려면 로그인하십시오.

Display Format for Numeric Values

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 =

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

x = [4/3 1.2345e-6]
x =
    1.3333    0.0000

Set the format to 5-digit floating point:

format short e
x =
   1.3333e+00   1.2345e-06

Set the format to 15-digit scaled fixed point:

format long
x =
   1.333333333333333   0.000001234500000

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

format rational
x =
     4/3          1/810045

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

format hex
x = uint32(876543210)
x =

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:

origFormat = get(0, 'format');

  -- Work in rational format --

set(0,'format', origFormat);
Was this topic helpful?