isfinite - Determine which array elements are finite - MATLAB (original) (raw)
Main Content
Determine which array elements are finite
Syntax
Description
TF = isfinite([A](#mw%5Fb698ee9c-56bf-4c33-b5df-f498e7afa625))
returns a logical array containing 1
(true
) where the elements of the arrayA
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
.
Examples
Create a row vector and determine the finite real elements.
A = 1×5
-0.5000 -1.0000 Inf 1.0000 0.5000
TF = 1×5 logical array
1 1 0 1 1
Create an array of complex numbers. Determine whether the complex numbers contain finite values.
A = 1×3 complex
2.0000 + 1.0000i 3.0000 + Infi NaN - 2.0000i
TF = 1×3 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
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 logical1
(true
).
Extended Capabilities
Theisfinite
function fully supports tall arrays. For more information, see Tall Arrays.
The isfinite
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