In Matlab I often want to assign multiple values from a numeric vector to a given field of a structure array.
b = 1:3;
x(1).a = b(1);
x(2).a = b(2);
x(3).a = b(3);
It seems like there should be a way to make this assignment in a single line but two lines is the best I can come up.
c = num2cell(b);
[x.a] = c{:};
Is there a way to convert a numeric vector into a comma-separated list? I'm looking for something like:
[x.a] = num2csl(b);
Note that I am assuming that length(x) == length(b) here.
[x.a] =num2cell(b){:};