Dictionary with key-value pair of string ---> string array?
36 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
the cyclist
le 6 Avr 2024 à 22:08
Modifié(e) : the cyclist
le 7 Avr 2024 à 0:46
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 commentaires
Réponse acceptée
Paul
le 6 Avr 2024 à 22:59
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 commentaire
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Characters and Strings dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!