Documentation

isinf

Determine which array elements are infinite

Syntax

Description

example

TF= isinf(A)returns a logical array containing1(true) where the elements of the arrayAareInfor-Inf, and0(false) where they are not. IfAcontains complex numbers,isinf(A)contains1for elements with infinite real or imaginary part, and0for elements where both real and imaginary parts are finite orNaN.

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 array0 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 complex2.0000 + 1.0000i 3.0000 + Infi NaN - 2.0000i
TF = isinf(A)
TF =1x3 logical array0 1 0

The second element ofAhas an infinite imaginary part. For this element,isinfreturns 1.

Input Arguments

collapse all

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

Tips

  • Ifxis a real scalar, exactly one ofisfinite(x),isinf(x), andisnan(x)returns logical1(true).

  • For a complex scalarz,isinf(z)andisnan(z)can both return logical 1. For example,isinf(complex(Inf,NaN))andisnan(complex(Inf,NaN))both return logical 1.

Extended Capabilities

C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.

See Also

||

Introduced before R2006a