MATLAB: Does comma-separated assignment to a structure not work when the structure is indexed in MATLAB 7.8 (R2009a)

assignassignmentcommaMATLABseparatedstructstructure

When I use comma-separated assignment to a structure array to add more data to an existing array, I get an error when I provide an index to specify where in the structure the comma-separated list should be assigned.
For example, executing the following code
s = struct('married', {true false false true});
C = {'joe' 'mary' 'jane' 'pete'
36 24 32 54 }';
[s(1:4).name, s(1:4).age] = C{1:4,:}
returns this error:
??? Insufficient outputs from right hand side to satisfy comma separated
list expansion on left hand side. Missing [] are the most likely cause.

Best Answer

The ability to do use a comma-separated assignment like this is not available in MATLAB.
To work around this issue, assign one field at a time. For example:
[s(1:4).name] = C{1:4,1};
[s(1:4).age] = C{1:4,2};