Error using containers.Map
显示 更早的评论
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.
采纳的回答
更多回答(1 个)
Walter Roberson
2016-11-30
0 个投票
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
类别
在 帮助中心 和 File Exchange 中查找有关 Logical 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!