I have a vector of structs each having a field x:
s1.x = 1;
s2.x = 2;
s3.x = 3;
S = [s1, s2, s3];
I would like to set the field x of all structs in S from a given vector X, i.e. I would like to vectorize the following loop:
X = [97, 98, 99];
for i = 1 : length(S)
S(i).x = X(i);
end
Is this possible?