MATLAB Programming Fundamentals - MathWorks

(やまだぃちぅ) #1
ans =
'2R175' '417R93' '947F4' 'A479GY' 'B7398' 'NZ1452'

ans =
'James Enright' 'Patricia Hughes' 'Susan Spera' 'Sarah Latham' 'Carl Haynes' 'Bradley Reid'


  • Concatenation does not include duplicate keys or their values in the resulting Map
    object.


In the following example, both objects m1 and m2 use a key of 8. In Map m1, 8 is a key
to value C; in m2, it is a key to value X:

m1 = containers.Map({1, 5, 8}, {'A', 'B', 'C'});
m2 = containers.Map({8, 9, 6}, {'X', 'Y', 'Z'});

Combine m1 and m2 to form a new Map object, m:

m = [m1; m2];

The resulting Map object m has only five key/value pairs. The value C was dropped
from the concatenation because its key was not unique:

keys(m), values(m)

ans =

[1] [5] [6] [8] [9]

ans =

'A' 'B' 'Z' 'X' 'Y'

See Also
containers.Map | isKey | keys | values

Related Examples



  • “Create Map Object” on page 14-6

  • “Examine Contents of Map” on page 14-9


14 Map Containers

Free download pdf