【发布时间】:2011-12-14 06:42:11
【问题描述】:
假设我在 MATLAB 中有以下内容:
a(1).b.c = 4;
a(2).b.c = 5;
a(3).b.c = 7;
....
我想将值 [4 5 7 ...] 收集到一个数组中,不循环并以矢量化方式。
我试过了:
>> a(:).b.c
# Error: Scalar index required for this type of multi-level indexing.
和
>> a.b.c
# Error: Dot name reference on non-scalar structure.
但他们没有工作。我能想到的最好的方法是:
arrayfun(@(x) x.b.c, a);
但据我了解arrayfun 是not vectorized,还是这样?
【问题讨论】:
标签: matlab