allfinite - Determine if all array elements are finite - MATLAB (original) (raw)
Main Content
Determine if all array elements are finite
Since R2022a
Syntax
Description
`TF` = allfinite([A](#mw%5Fa7aa6c46-8583-43b9-ad73-47e178378220))
returns logical 1
(true
) if all elements ofA
are finite. It returns 0
(false
) if any element is not finite.
If A
contains complex numbers, allfinite(A)
returns 1
if all elements have finite real and imaginary parts, and0
otherwise.
Examples
Create a row vector and determine if all elements are finite.
A = 1×4 1023 ×
-0.0000 -0.0000 1.0000 0.0000
Create another row vector and determine if all elements are finite.
Create a matrix and determine if all elements are finite.
A = [0 0 3;0 0 3;0 0 NaN]
A = 3×3
0 0 3
0 0 3
0 0 NaN
Create a 3-D array and determine if all elements are finite.
A(:,:,1) = [2 1; 3 5]; A(:,:,2) = [0 0; 0 Inf]; A(:,:,3) = [-2 9; 4 1]
A = A(:,:,1) =
2 1
3 5
A(:,:,2) =
0 0
0 Inf
A(:,:,3) =
-2 9
4 1
Create a vector of complex numbers. Determine if all elements are finite.
A = 1×3 complex
2.0000 + 3.0000i Inf + 1.0000i 0.0000 - 2.0000i
allfinite(A)
returns 0
because the second element of A
has a real part that is infinite.
Input Arguments
Input array, specified as a scalar, vector, matrix, or multidimensional array.
Example: [pi NaN Inf -Inf]
Data Types: single
| double
| int8
| int16
| int32
| int64
| uint8
| uint16
| uint32
| uint64
| logical
| char
| datetime
| duration
| calendarDuration
Complex Number Support: Yes
Extended Capabilities
Theallfinite
function fully supports tall arrays. For more information, see Tall Arrays.
The allfinite
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 in R2022a