Use a numeric array as Map value
6 次查看(过去 30 天)
显示 更早的评论
I'm reading through a file and want to create a map of string keys, each with an array of numeric arrays. How do I go about declaring this object and then appending arrays to the values?
回答(1 个)
Cedric
2015-7-19
编辑:Cedric
2015-7-19
If I understand well what you are trying to achieve, you can:
- Build your own system using a cell array of keys and STRCMP/STRCMPI/REGEXP for matching key/value pairs.
- Use a containers.Map object.
- Use a Java Hashtable object ( java.util.Hashtable )
Note that if you need to store complex data structures, a good option is to use a hybrid approach, where you define a values cell array, a keys hashtable, and then store complex data structures in the cell array and only their IDs in the hashtable.
5 个评论
Cedric
2015-7-20
编辑:Cedric
2015-7-20
If all you need to implement is this Python-dict-like feature, yes. But if you really have to iterate through files and then use MATLAB for performing some type of processing, then you should stick to MATLAB. The last two mechanisms that I mention are close to Python dictionary objects; learning to use them is much easier than interfacing Python and MATLAB.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Python Package Integration 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!