The following names have special values in Matlab.
Value | Comment |
---|---|
ans | the last computed answer |
eps | the smallest number such that 1 + eps ~= 1 |
realmin | the smallest representable positive real number |
realmax | the largest representable positive real number |
pi | 3.141592653589... |
i, j | sqrt(-1) |
Inf | IEEE representation of positive infinity (1/0, factorial(200) |
NaN | IEEE representation of not-a-number (inf - inf, 0/0) |
To get the value e = 2.7182818284..., use exp(1).
The following boolean valued queries are available to test for various values. They map onto matrices.
The function isfinite returns true if the number is any floating point value which is not NaN or Inf.
The function isinf tests if either the real or imaginary part of a number is infinity. For example, the following are all recognized as infinity: Inf, -Inf + NaN*i, and -Inf*i.
The function isnan tests if either the real or imaginary part of a number is not-a-number. A requirement of IEEE numerics is that NaN does not compare to itself, as can be seen in the following example:
>> NaN == NaN ans = 0 >> isnan( NaN ) ans = 1