%% Return Values and Field Names
% Create a structure.

S.x = linspace(0,2*pi);
S.y = sin(S.x);
S.title = 'y = sin(x)'

%
% Convert S to a cell array.

C = struct2cell(S)

%
% The cell array does not include field names. To return the field names in a cell array, use the fieldnames function. fieldnames and struct2cell return the field names and the values in the same order.

fields = fieldnames(S)

% Copyright 2018 The MathWorks, Inc.