Main Content

isequaln

Test symbolic objects for equality, treating NaN values as equal

Description

tf = isequaln(A,B) returns logical 1 (true) if A and B are the same size and their contents are of equal value. Otherwise, isequaln returns logical 0 (false). All NaN (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 logical 1 (true).

example

tf = isequaln(A1,A2,...,An) returns logical 1 (true) if all the inputs are equal.

example

Examples

collapse all

Use isequaln to compare these two expressions.

syms x
tf = isequaln(abs(x),x)
tf = logical
   0

For positive x, these expressions are identical.

assume(x > 0)
tf = isequaln(abs(x),x)
tf = logical
   1

For further computations, remove the assumption on x by recreating it using syms.

syms x

Use isequaln to compare these two matrices.

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

Use isequaln to compare these vectors.

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

Input Arguments

collapse all

Inputs to compare, specified as symbolic numbers, scalar variables, matrix variables, expressions, functions, matrix 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, scalar variables, matrix variables, expressions, functions, matrix 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

  • isequaln(A,B) checks if A and B are the same size and their contents are equal (from coding perspective), treating NaN values as equal. To check whether the mathematical comparison A == B holds for all values of variables in A and B, use isAlways(A == B).

  • If one of the input arguments is a symbolic type and the other input is a MATLAB® numeric type with the same value, then isequaln returns logical 0 (false) because the inputs are not equal (from coding perspective). For example, tf = isequaln(1,sym(1)) returns 0 (false).

Version History

Introduced in R2013a

expand all