Say I have the following in MATLAB:
a(1).b.c = 4;
a(2).b.c = 5;
a(3).b.c = 7;
....
I would like to collect the values [4 5 7 ...]
in a single array, without looping and in a vectorized manner.
I have tried:
>> a(:).b.c
# Error: Scalar index required for this type of multi-level indexing.
and
>> a.b.c
# Error: Dot name reference on non-scalar structure.
but they didn't work. The best I could come up with was:
arrayfun(@(x) x.b.c, a);
but as far as I understand arrayfun
is not vectorized, or is it?