%% Elements of Field
% Create a structure with a field whose value is an array.

S.a = [5 10 15 20 25]

%
% Assign values to elements of S.a using the setfield function. To assign values to particular elements, specify indices after the name of the field. You must specify the indices within a cell array. However, specify the new values in an array whose data type matches the data type of the field.

S = setfield(S,'a',{3:5},[0 -50 -100])

%
% You also can use dot notation and array indexing to assign values to the same elements.

S.a(3:5) = [20 40 80]

% Copyright 2018 The MathWorks, Inc.