Dictionary with key-value pair of string ---> string array?
24 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
Paul
2024-4-6
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"}
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Dictionaries 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!