Dictionary with key-value pair of string ---> string array?
25 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
the cyclist
am 6 Apr. 2024
Bearbeitet: the cyclist
am 7 Apr. 2024
Using the older containers.Map object, I can map a string to a string array:
keySet = ["Jan";"Feb";"Mar"];
valueSet = {["New Year","MLK"]; ["Valentine's","Presidents'"];[]};
M = containers.Map(keySet,valueSet);
M("Jan")
I have not found a way to make a similar mapping via the newer dictionary object (even though the documentation states that a dictionary is preferred "because it supports more data types as keys and values and provides better performance").
Maybe I'm overlooking something. Any suggestions are appreciated.
0 Kommentare
Akzeptierte Antwort
Paul
am 6 Apr. 2024
Hi cyclist,
Do you mean mapping to the string array contained inside the cell?
keySet = ["Jan";"Feb";"Mar"];
valueSet = {["New Year","MLK"]; ["Valentine's","Presidents'"];[]};
d = dictionary(keySet,valueSet)
d("Jan")
d{"Jan"}
1 Kommentar
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Dictionaries finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!