23.06.2015 Views

MATLAB Programming

MATLAB Programming

MATLAB Programming

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

2 Data Types<br />

All available formats are listed on the format reference page.<br />

To change the numeric display setting, use either the format function or<br />

the Preferences dialog box (accessible from the <strong>MATLAB</strong> File menu). The<br />

format function changes the display of numeric values for the duration of a<br />

single <strong>MATLAB</strong> session, while your Preferences settings remain active from<br />

one session to the next. These settings affect only how numbers are displayed,<br />

not how <strong>MATLAB</strong> computes or saves them.<br />

Display Format Examples<br />

Here are a few examples of the various formats and the output produced from<br />

the following two-element vector x, with components of different magnitudes.<br />

Check the current format setting:<br />

get(0, 'format')<br />

ans =<br />

short<br />

Set the value for x and display in 5-digit scaled fixed point:<br />

x = [4/3 1.2345e-6]<br />

x =<br />

1.3333 0.0000<br />

Set the format to 5-digit floating point:<br />

format short e<br />

x<br />

x =<br />

1.3333e+000<br />

1.2345e-006<br />

Set the format to 15-digit scaled fixed point:<br />

format long<br />

x<br />

x =<br />

1.33333333333333 0.00000123450000<br />

Set the format to 'rational' for small integer ratio output:<br />

2-28

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!