Check whether symbolic array elements are infinite
isinf(
returns an array of the same size asA
)A
containing logical1
s (true) where the elements ofA
are infinite, and logical0
s (false) where they are not. For a complex number,isinf
returns1
if the real or imaginary part of that number is infinite or both real and imaginary parts are infinite. Otherwise, it returns0
.
Usingisinf
, determine which elements of this symbolic matrix are infinities:
isinf(sym([pi NaN Inf; 1 + i Inf + i NaN + i]))
ans = 2×3 logical array 0 0 1 0 1 0
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 infinite:
cot(V) isinf(cot(V))
ans = [ Inf, Inf, Inf, Inf] ans = 1×4 logical array 1 1 1 1
Nevertheless, the cotangents of the approximated values are not infinite due to the round-off errors:
isinf(cot(V_approx))
ans = 1×4 logical array 0 0 0 0
For anyA
, exactly one of the three quantitiesisfinite(A)
,isinf(A)
, orisnan(A)
is1
for each element.
The elements ofA
are recognized as infinite if they are
SymbolicInf
or-Inf
Sums or products containing symbolicInf
or-Inf
and not containing the valueNaN
.