isequal
isequal(A1,A2,...,An)returns logical1when A1, …, An are identical- Indeterminate elements such as
NaNare treated as unequal to any value, including themselves
- Indeterminate elements such as
Equivalent
| Type of A, B | Condition for isequal(A,B) == 1 |
|---|---|
| numeric | same size + equal values (both real and imaginary parts) |
| string scalar, character vector | contain the same sequence of characters |
| structure | same field names + same field contents (fields need not be in the same order) |
| table, timetable, cell array | all elements and properties are equal |
| function handle | both refer to the same named function, or are copies of the same anonymous one |
| ordinal categorical array | same set of categories + same order |
| object | same class + equal property values |
- For a categorical array that is not ordinal, the two arrays may have different sets of categories;
isequalcompares the category names of each pair of elements - For datetime arrays,
isequalignores display format when comparing points in time. If the arrays are all associated with time zones,isequalcompares 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, soisequalreturns 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