I have created a container.Map object to store a structure as the value for a given key. The structure has two fields, the date which is a number and a remark for each date. While I could store this as a cell array (due to the different variable types), I like to use structures as it seems to help make the code more readable. I can populate the Map object with the data, unfortunately, when I try to list all of the remarks for a given key, it only returns one entry. What is the correct way to get a list of all the remarks for a given key?
I am running Matlab 8.1.0.604 (R2013a) with Java version 1.6.0_17-b04
Example code is as follows
% Create a new Map object
a = containers.Map;% Create some silly data to store in it
times = datenum(2013, 1, 1, 0, 0, 0):1:datenum(2013, 1, 10, 0, 0, 0);remarks = repmat({'Test String'}, 10, 1);tmp = struct('Time', times, 'Remark', remarks);% Insert the data into three different keys
a('One') = tmp;a('Two') = tmp;a('Three') = tmp;% Now lets try to list all of the remarks associated with 'Two'
a('Two').Remark
I would like to be able to do something like:
{tmp.Remark}'ans = 'Test String' 'Test String' 'Test String' 'Test String' 'Test String' 'Test String' 'Test String' 'Test String' 'Test String' 'Test String'
I would like to replace the tmp. in the last command to something like
{a('Two').Remark}'
When I do that I only get one line back. Thanks for any help on this.
Best Answer