Programming and Data Types |
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. |
realmax |
Largest floating-point number your computer can represent. |
realmin |
Smallest 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 . n/0 , where n is complex, also returns NaN . |
computer |
Computer type. |
version |
MATLAB version string. |
Here are several examples that use these values in MATLAB expressions.
Persistent Variables | Data Types |