Section 1.5 Display Formats
One can control the format in which MATLAB displays (echos) output to the command window:
- The default format is fixed-point with 4 decimal digits.
- Issue the format command (see below for some examples) to change the output for the remainder of the session.
- The output format does not change the way that MATLAB computes and stores numbers.
- The default data type is a double-precision array which means that by default, any number is stored with double-precision (which means using 64 bits).
- Using 64 bits, number you can store range from 2.225073858507201e-308 to 1.797693134862316e+308
Display Format | Description | Example |
format short | fixed-point with 4 decimal digits for \(0.001 \leq\) number \(\leq 1000\text{,}\) otherwise uses short e |
>> 290/7 ans = 41.4286 |
format long | fixed-point with 15 decimal digits for \(0.001 \leq\) number \(\leq 1000\text{,}\) otherwise uses long e |
>> 290/7 ans = 41.42857142857143 |
format short e | scientific notation with 4-decimal digits |
>> 290/7 ans = 4.1429e+001 |
format long e | scientific notation with 15-decimal digits |
>> 290/7 ans = 4.142857142857143e+001 |
format short g | best of 5-digit or scientific notation |
>> 290/7 ans = 41.429 |
format long g | best of 15-digit or scientific notation |
>> 290/7 ans = 41.4285714285714 |
format bank | Two decimal digits |
>> 290/7 ans = 41.43 |
format compact | eliminates empty lines |
|
format loose | adds empty lines |