Programming Previous page   Next Page

Special Values

Several functions return important special values that you can use in your M-files.

Function
Return Value
ans
Most recent answer (variable). If you do not assign an output variable to an expression, MATLAB automatically stores the result in ans.
eps
Floating-point relative accuracy. This is the tolerance MATLAB uses in its calculations.
intmax
Largest 8-, 16-, 32-, or 64-bit integer your computer can represent.
intmin
Smallest 8-, 16-, 32-, or 64-bit integer your computer can represent.
realmax
Largest floating-point number your computer can represent.
realmin
Smallest positive floating-point number your computer can represent.
pi
3.1415926535897...
i, j
Imaginary unit.
inf
Infinity. Calculations like n/0, where n is any nonzero real value, result in inf.
NaN
Not a Number, an invalid numeric value. Expressions like 0/0 and inf/inf result in a NaN, as do arithmetic operations involving a NaN. Also, if n is complex with a zero real part, then n/0 returns a value with a NaN real part.
computer
Computer type.
version
MATLAB version string.

Here are some examples that use these values in MATLAB expressions.


Previous page  Keywords Operators Next page

© 1994-2005 The MathWorks, Inc.