Main Content

isfinite

Check whether symbolic array elements are finite

Syntax

Description

example

isfinite(A)returns an array of the same size asAcontaining logical1s (true) where the elements ofAare finite, and logical0s (false) where they are not. For a complex number,isfinitereturns1if both the real and imaginary parts of that number are finite. Otherwise, it returns0.

Examples

Determine Which Elements of Symbolic Array Are Finite Values

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

isfinite(sym([pi NaN Inf; 1 + i Inf + i NaN + i]))
ans = 2×3 logical array 1 0 0 1 0 0

Determine if 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:

cot(V) isfinite(cot(V))
ans = [ Inf, Inf, Inf, Inf] ans = 1×4 logical array 0 0 0 0

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

isfinite(cot(V_approx))
ans = 1×4 logical array 1 1 1 1

Input Arguments

collapse all

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

Tips

  • For anyA, exactly one of the three quantitiesisfinite(A),isinf(A), orisnan(A)is1for each element.

  • Elements ofAare recognized as finite if they are

    • Not symbolicNaN

    • Not symbolicInfor-Inf

    • Not sums or products containing symbolic infinitiesInfor-Inf

Introduced in R2013b