Check whether symbolic array elements are finite




isfinite(A) returns an array of the same size as A containing logical 1s (true) where the elements of A are finite, and logical 0s (false) where they are not. For a complex number, isfinite returns 1 if both the real and imaginary parts of that number are finite. Otherwise, it returns 0.


Determine Which Elements of a Symbolic Array Are Finite Values

Using isfinite, determine which elements of this symbolic matrix are finite values:

isfinite(sym([pi NaN Inf; 1 + i Inf + i NaN + i]))
ans =
     1     0     0
     1     0     0

Determine If the Exact and Approximated Values Are Finite

Approximate these symbolic values with the 50-digit accuracy:

V = sym([pi, 2*pi, 3*pi, 4*pi]);
V_approx = vpa(V, 50);

The cotangents of the exact values are not finite:

ans =
[ Inf, Inf, Inf, Inf]
ans =
     0     0     0     0

Nevertheless, the cotangents of the approximated values are finite due to the round-off errors:

ans =
     1     1     1     1

Input Arguments

expand all

A — Input valuesymbolic number | symbolic variable | symbolic expression | symbolic function | symbolic array | symbolic vector | symbolic matrix

Input value, specified as a symbolic number, variable, expression, or function, or as an array, vector, or matrix of symbolic numbers, variables, expressions, functions.

More About

expand all


  • For any A, exactly one of the three quantities isfinite(A), isinf(A), or isnan(A) is 1 for each element.

  • Elements of A are recognized as finite if they are

    • Not symbolic NaN

    • Not symbolic Inf or -Inf

    • Not sums or products containing symbolic infinities Inf or -Inf

See Also

| | | | |

Was this topic helpful?