MATLAB Answers

Use a numeric array as Map value

23 views (last 30 days)
Ben
Ben on 19 Jul 2015
Commented: Ben on 22 Jul 2015
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?

Answers (1)

Cedric Wannaz
Cedric Wannaz on 19 Jul 2015
Edited: Cedric Wannaz on 19 Jul 2015
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 Comments
Ben
Ben on 22 Jul 2015
Eh, in the end it was easy enough just to save the relevant information to files with Python, then process it further in Matlab.

Sign in to comment.

Tags

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!