Main Content

isfinite

Determine which array elements are finite

Description

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

example

Examples

collapse all

Create a row vector and determine the finite real elements.

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

   -0.5000   -1.0000       Inf    1.0000    0.5000

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

   1   1   0   1   1

Create an array of complex numbers. Determine whether the complex numbers contain finite 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 = isfinite(A)
TF = 1x3 logical array

   1   0   0

The second element of A has an infinite imaginary part. The third element has a NaN real part. For both of these elements, isfinite returns 0.

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).

Extended Capabilities

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

HDL Code Generation
Generate VHDL, Verilog and SystemVerilog code for FPGA and ASIC designs using HDL Coder™.

Version History

Introduced before R2006a