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 the MATLAB software 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.

x = 2 * pi
x =
   6.2832

A = [3+2i 7-8i]
A =
   3.0000 + 2.0000i   7.0000 - 8.0000i

tol = 3 * eps
tol =
   6.6613e-016

intmax('uint64')
ans =
   18446744073709551615
  


 © 1984-2008- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS