Although I would say @Dan answer is pretty canon for this question, I would like to introduce an alternative:
s(1).f = (1:3);
s(2).f = (4:6);
s(3).f = (7:9);
[q(1:length(s)).f] = s.f;
Although it is a bit more verbose than the syntax [q.f] = s.f, it does have the advantage of functioning as expected, even if qit was not pre-assigned to the correct size to be a copy s.
For instance:
s(1).f = (1:3);
s(2).f = (4:6);
s(3).f = (7:9);
[q.f] = s.f;
Returns q.fas 1x1 struct, equals(1).f
source
share