# isinf

Determine which array elements are infinite

## Description

example

TF = isinf(A) returns a logical array containing 1 (true) where the elements of the array A are Inf or -Inf, and 0 (false) where they are not. If A contains complex numbers, isinf(A) contains 1 for elements with infinite real or imaginary part, and 0 for elements where both real and imaginary parts are finite or NaN.

## Examples

collapse all

Create a row vector and determine the infinite elements.

A = 1./[-2 -1 0 1 2]
A = 1×5

-0.5000   -1.0000       Inf    1.0000    0.5000

TF = isinf(A)
TF = 1x5 logical array

0   0   1   0   0

Create an array of complex numbers. Determine whether the complex numbers contain infinite values.

A = [2 + 1i, 3 + 1i/0, 0/0 - 2i]
A = 1×3 complex

2.0000 + 1.0000i   3.0000 +    Infi      NaN - 2.0000i

TF = isinf(A)
TF = 1x3 logical array

0   1   0

The second element of A has an infinite imaginary part. For this element, isinf returns 1.

## Input Arguments

collapse all

Input array, specified as a scalar, vector, matrix, or multidimensional array.

## Tips

• If x is a real scalar, exactly one of isfinite(x), isinf(x), and isnan(x) returns logical 1 (true).

• For a complex scalar z, isinf(z) and isnan(z) can both return logical 1. For example, isinf(complex(Inf,NaN)) and isnan(complex(Inf,NaN)) both return logical 1.