MATLAB: How do apply DEAL to distribute an array or matrix to a structure in MATLAB 7.7 (R2008b)

MATLAB

I have an array and I wish to distribute it across a strucuture in one line as below;
x=[1,2,3];
I wish to distribute this to structure S as such in one line, such that;
S(1).field = 1;
S(2).field = 2;
S(3).field = 3;

Best Answer

There is currently no way to do this distribution in one line in MATLAB 7.7 (R2008b). The workaround requires two lines of code and is as follows;
x= [1,2,3];
y=num2cell(x);
[S(1:3).fieldname]=deal(x{:});
Related Question