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

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

%
% Return the field names in a cell array using the fieldnames function.

fields = fieldnames(S)

%
% To return the values of the fields, use the struct2cell function. struct2cell and fieldnames return the values and the field names in the same order.

values = struct2cell(S)

% Copyright 2018 The MathWorks, Inc.