Floating-point numbers may be entered as either integers, decimal floating-point numbers, or using the or using the e notation:
>> 3 ans = 3 >> 3253235.23 ans = 3.2532e+06 >> 32.2523e-3 ans = 0.0323
Note that the input does not necessarily reflect on the way the number is displayed.
If the largest number in a matrix would be written using the e notation, the appropriate multiple of 10 is taken outside of matrix:
>> [225323.23 523.23] ans = 1.0e+05 * 2.2542 0.0052 >> [3.2376 9.2534e-7] ans = 3.2376 0.0000 >> [728, 725324547] ans = 1.0e+10 * 0.0000 7.2532
There are a number of formats in which you can use to display the results. You may invoke any of the formats by typing format **** where **** is the format. Note, that there are no parentheses.
Name | Description | Comments |
---|---|---|
short | Scaled fixed point format with 5 digits. | default |
long | Scaled fixed point format with 15 digits. | full precision in decimal format |
short e | Floating point format with 5 digits. | |
long e | Floating point format with 15 digits. | |
short g | Best of fixed or floating point format with 5 digits. | |
long g | Best of fixed or floating point format with 15 digits. | |
hex | Hexadecimal fomrat. | the internal represetation of the double precision floating-point numbers. |
+ | The symbols +, - and blank are printed for positive, negative, and zero elements. Imaginary parts are ignored. | |
bank | Fixed formats for dollars and cents. | |
rat | Approximation by ratio of small integers. |
Two other formats are used for line spacing: loose (the default), and compact (suppresses extra line-feeds.)
Examples:
>> a = 1/5323 a = 1.8786e-04 >> format long >> a a = 1.878639864737930e-04 >> format hex >> a a = 3f289fab5b22f6b8 >> format % same as format short >> a = 2.3 a = 2.3 >> format long e a = 2.300000000000000e+00