Main Content

isequaln

Test symbolic objects for equality, treatingNaNvalues as equal

Description

example

isequaln(A,B)returns logical1(true) ifAandBare the same size and their contents are of equal value. Otherwise,isequalnreturns logical0(false). AllNaN(not a number) values are considered to be equal to each other.isequalnrecursively compares the contents of symbolic data structures and the properties of objects. If all contents in the respective locations are equal,isequalnreturns logical1(true).

example

isequaln(A1,A2,...,An)returns logical1(true) if all the inputs are equal.

Examples

Compare Two Expressions

Useisequalnto 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 onxby recreating it usingsyms:

syms x

Compare Two Matrices

Useisequalnto compare these two matrices:

A = hilb(3); B = sym(A); isequaln(A, B)
ans = logical 0

Compare Vectors ContainingNaNValues

Useisequalnto compare these vectors:

syms x A1 = [x NaN NaN]; A2 = [x NaN NaN]; A3 = [x NaN NaN]; isequaln(A1, A2, A3)
ans = logical 1

Input Arguments

collapse all

Inputs to compare, specified as symbolic numbers, variables, expressions, functions, vectors, or matrices. If one of the arguments is a symbolic object and the other one is numeric, the toolbox converts the numeric object to symbolic before comparing them.

Series of inputs to compare, specified as symbolic numbers, variables, expressions, functions, vectors, or matrices. If at least one of the arguments is a symbolic object, the toolbox converts all other arguments to symbolic objects before comparing them.

Tips

  • Callingisequalnfor arguments that are not symbolic objects invokes the MATLAB®isequalnfunction. If one of the arguments is symbolic, then all other arguments are converted to symbolic objects before comparison.

Introduced in R2013a