isinf - Determine which array elements are infinite - MATLAB (original) (raw)

Main Content

Determine which array elements are infinite

Syntax

Description

`TF` = isinf([A](#mw%5F0c0d8d79-3d05-4d0b-8256-8544ee6fcdd9)) returns a logical array containing 1 (true) where the elements of the array A are Inf or -Inf, and0 (false) where they are not. IfA contains complex numbers, isinf(A) contains1 for elements with infinite real or imaginary part, and0 for elements where both real and imaginary parts are finite orNaN.

example

Examples

collapse all

Create a row vector and determine the infinite elements.

A = 1×5

-0.5000 -1.0000 Inf 1.0000 0.5000

TF = 1×5 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 = 1×3 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

Extended Capabilities

expand all

Theisinf function fully supports tall arrays. For more information, see Tall Arrays.

The isinf function fully supports GPU arrays. To run the function on a GPU, specify the input data as a gpuArray (Parallel Computing Toolbox). For more information, see Run MATLAB Functions on a GPU (Parallel Computing Toolbox).

Version History

Introduced before R2006a