Error using containers.Map
Show older comments
Hello, I am having following problem. I want to display single cells from my string array if my function finds a specific string. Here is the code:
function voddi_test(graph)
global vodcode
system_name = extract_system_name(graph);
variables = containers.Map();
variable = containers.Map();
keys = variables.keys;
for name = variables.keys
variable(name{1}) = true;
end
for node_name = filter_graph(graph, 'Variable', true)
node = graph(node_name{1});
for arg = node.arguments
variables([system_name '/' arg{1}]) = true;
end
end
for keys = 1:numel(variables)
if strcmp(variables(keys), 'Constant')
variables(keys{1})
else
variables(keys{2})
end
end
end
I am keeping getting the error message "Specified key type does not match the type expected for this container" when I try compare the content of the variables map with my desired strings. The code works fine, expect for the last for - loop. Any help is much appreciated, many thanks.
Accepted Answer
More Answers (1)
Walter Roberson
on 30 Nov 2016
0 votes
You create variables as an empty map. It has no keys. So your first for loop does nothing so no keys are created for variable
Categories
Find more on Logical 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!