%% Assign Values to Multiple Cells
% Create a 1-by-3 cell array whose cells are empty.

C = cell(1,3)

%
% Create three variables. Assign their values to cells of C by using deal. The syntax C{:} creates a comma-separated list of cells whose contents you can access by using curly braces. You can treat this list as a list of output arguments when calling deal.

A1 = 100;
A2 = "foo";
A3 = 1:5;
[C{:}] = deal(A1,A2,A3)

%
% If the cell array does not exist, then you can create it by specifying enough indices to accommodate the values you assign. You can also use indices to assign values to a subset of cells. For example, if C were a 1-by-6 cell array, this syntax would assign values to the first three cells.

[C{1:3}] = deal(A1,A2,A3)

% Copyright 2020 The MathWorks, Inc.