keyMatch - Determine if two dictionary keys are the same - MATLAB (original) (raw)
Main Content
Determine if two dictionary keys are the same
Since R2022b
Syntax
Description
`tf` = keyMatch([A](#mw%5F261790ac-2c1b-44b6-a4d7-45daa1294a7f),[B](#mw%5F261790ac-2c1b-44b6-a4d7-45daa1294a7f))
returns 1
(true
) if arrays A
andB
are the same class, properties, dimensions, and values and returns0
(false
) otherwise.
NaN
, NaT
, <undefined>
categorical elements, and <missing>
values are considered to be equal to other such values. Handle objects match if they are the same handle.
The keyMatch
function determines equivalence on the properties of the input. For custom classes keyMatch
may need to be overloaded to ensure correct equivalence. For more information on using custom classes with dictionary, see Dictionaries and Custom Classes
Examples
Dictionaries map unique keys to values. Use the function keyMatch
to determine if keys are the same.
Create two structures with two fields.
X = struct("field1",1,"field2",2); Y = struct("field1",1,"field2",2);
Use keyMatch
to determine if X
and Y
are the same as dictionary keys.
Change field1
of Y
so that X
and Y
are different as dictionary keys.
Y.field1 = 3; keyMatch(X,Y)
Input Arguments
Inputs to be compared, specified as scalars, vectors, matrices, or multidimensional arrays
Version History
Introduced in R2022b