Test symbolic objects for equality, treatingNaN
values as equal
isequaln(
returns logicalA,B
)1
(true) ifA
andB
are the same size and their contents are of equal value. Otherwise,isequaln
returns logical0
(false). AllNaN
(not a number) values are considered to be equal to each other.isequaln
recursively compares the contents of symbolic data structures and the properties of objects. If all contents in the respective locations are equal,isequaln
returns logical1
(true).
isequaln(
returns logicalA1,A2,...,An
)1
(true) if all the inputs are equal.
Useisequaln
to compare these two expressions:
syms x isequaln(abs(x), x)
ans = logical 0
积极x
, these expressions are identical:
assume(x > 0) isequaln(abs(x), x)
ans = logical 1
For further computations, remove the assumption onx
by recreating it usingsyms
:
syms x
Useisequaln
to compare these two matrices:
A = hilb(3); B = sym(A); isequaln(A, B)
ans = logical 0
NaN
ValuesUseisequaln
to compare these vectors:
syms x A1 = [x NaN NaN]; A2 = [x NaN NaN]; A3 = [x NaN NaN]; isequaln(A1, A2, A3)
ans = logical 1
Callingisequaln
for arguments that are not symbolic objects invokes the MATLAB®isequaln
function. If one of the arguments is symbolic, then all other arguments are converted to symbolic objects before comparison.