I need to build something like a python dictionary. I need to fill it dynamically, using numbers as keys and arrays as values. Specifically:
- I will want the object to be of the form
MyObj(1) = [1,2,3,4]
MyObj(2) = [10,20,30,40]
...
MyObj(n) = [val1, val2, val3, val4]
- I need it to be filled dynamically. I have two for loops. For each value of the outter loop, I declare an array and fill in the inner loop. At the end of this loop, I need to use the array as the value of MyObj.
I (think I) have managed to deal with the keys: for example I would do
keySet = ['1','2','3','4']
MyObj = containers.Map('KeyType','char','ValueType','?????????????');
for i=1:4
TheArrayToFill = [];
MyObj(keySet(i)) = TheArrayToFill
end
The idea is that, at the end, I get an object with 4 keys, with each key having a 50-cells numeric array as values. How can I accomplish this?
Note: I'm new to Matlab. I am using a container as it seemed the proper datastructure. If there is a better datastructure, I'll gladly switch to it. In this latter case, an example would be great.