MATLAB: Structs in struct, howto access

accessstructvariable

Hello,
I like to access a struct variable. A small example of the variable:
a(1).b.f1 = 11;
a(1).b.f2 = 12;
a(2).b.f1 = 21;
a(2).b.f2 = 22;
Now I like to access field f1 like:
a.b.f1
Matlab returns: Expected one output from a curly brace or dot indexing expression, but there were 2 results.
I expacted an output like
ans =
11
21
Is there a work around?
Thank you

Best Answer

arrayfun(@(S) S.b.f1, a(:) )