isequal

  • isequal(A1,A2,...,An) returns logical 1 when A1, …, An are identical
    • Indeterminate elements such as NaN are treated as unequal to any value, including themselves

Equivalent

Type of A, BCondition for isequal(A,B) == 1
numericsame size + equal values (both real and imaginary parts)
string scalar, character vectorcontain the same sequence of characters
structuresame field names + same field contents (fields need not be in the same order)
table, timetable, cell arrayall elements and properties are equal
function handleboth refer to the same named function, or are copies of the same anonymous one
ordinal categorical arraysame set of categories + same order
objectsame class + equal property values
  • For a categorical array that is not ordinal, the two arrays may have different sets of categories; isequal compares the category names of each pair of elements
  • For datetime arrays, isequal ignores display format when comparing points in time. If the arrays are all associated with time zones, isequal compares the instants in time rather than the clockface times (for example, 01-May-2018 09:00:00 EDT is the same instant as 01-May-2018 06:00:00 PDT, so isequal returns true even though the clockface times of 9:00 and 6:00 differ).

Generalized Numeric

The “numeric” row above is meant in the generalized sense and includes characters, logical values, integer types, and so on. For example, all of the following return logical true:

  • isequal(char(1), 1)
  • isequal(int8(1), 1)
  • isequal(true, 1)

Function Handles

  • For an anonymous function, two anonymous functions with the same expression and parameters can still be considered “different”; only handles obtained by copying via assignment are treated as equal
  • Two function handles referring to the same nested function are treated as equal only within the same call to their parent function