【发布时间】:2012-03-11 00:08:56
【问题描述】:
这是一个代码 sn-p,它显示了我想要的内容和错误,如下所示:
a = [1, 2];
m = containers.Map('KeyType','char', 'ValueType','any');
m('stackoverflow.com') = a;
pull_the_first_element_of_the_stored_array = m('stackoverflow.com')(1);
??? Error: ()-indexing must appear last in an index expression.
如何访问数组的元素,而数组元素又是地图对象的值? 我本来可以这样做的:
temp = m('stackoverflow.com');
pull_the_first_element_of_the_stored_array = temp(1);
但我不想创建一个中间数组只是为了从中提取一个值。
编辑:这是How can I index a MATLAB array returned by a function without first assigning it to a local variable?的副本,答案就在那里。
【问题讨论】:
-
@gnovice 确实如此。你能回答,指出你的解决方案吗?然后我会接受你的回答并投票结束这个问题。
标签: arrays matlab types map containers