end
[c1,c2,c3,c4,c5,c6] = C{1,1:6};
c5
c5 =
34
If you specify fewer output variables than the number of outputs returned by the
expression, MATLAB assigns the first N outputs to those N variables, and then discards
any remaining outputs. In this next example, MATLAB assigns C{1,1:3} to the variables
c1, c2, and c3, and then discards C{1,4:6}:
[c1,c2,c3] = C{1,1:6};
You can assign structure outputs in the same manner:
S = cell2struct(C,{'f1','f2','f3','f4','f5','f6'},2);
[sf1,sf2,sf3] = S.f5;
sf3
sf3 =
38
You also can use the deal function for this purpose.
Assigning to a Comma-Separated List
The simplest way to assign multiple values to a comma-separated list is to use the deal
function. This function distributes all of its input arguments to the elements of a comma-
separated list.
This example uses deal to overwrite each element in a comma-separated list. First create
a list.
c{1} = [31 07];
c{2} = [03 78];
c{:}
ans =
31 7
Comma-Separated Lists