How to properly create containers.Map of string as keys and structs as values?

6 views (last 30 days)
I have the following code:
[~,~,table] = xlsread(book,sheet);
% Drop the Ticker field, because it will be used as key.
fields = table(1,2:end);
% Use tickers as keys
K = table(2:end,1);
% the values are structures containing several info related to the key
% ticker.
V = cell2struct(table(2:end,2:end),fields,2);
%D = containers.Map ('KeyType','char','ValueType', 'any');
D = containers.Map(K,V);
V =
2x1 struct array with fields:
OpeningTime
ClosingTime
LabDays
Currency
CpOrd
Commission
IM
MM
Tendency
Period
Depth
RelProduct
RelWeight
Revision
and K =
'XAUUSD'
'XAGUSD'
but I have the following error message:
Error using containers.Map
Specified value type does not match the type expected for this container.
How can I fix it to get a Map indexed by means of a string and it get me the whole structure?

Answers (0)

Categories

Find more on Structures in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!