isinf
Marks elements that are positive or negative infinity.
Category: Language Fundamentals > Data Types
Syntax
tf = isinf(A)
Returns a logical array that is true where A is Inf or -Inf.
Description
NaN is not infinite, so isinf(NaN) is false. Integer arrays cannot hold infinity and always give all false.
The result is handy for masking: x(isinf(x)) = NaN replaces every infinity before computing statistics.
Input arguments
A- Numeric or logical array. Complex values count as infinite if either part is infinite.
Output arguments
tf- Logical array the same size as
A.
Example
Finding infinities
x = [1 Inf -Inf NaN 1/0];
isinf(x)
x(isinf(x)) = NaN
Output
ans = 1×5 logical array
0 1 1 0 1
x = 1×5
1 NaN NaN NaN NaN