%% Return Object Array
% Create a scalar structure in which each field contains an array of random numbers.

S.X = rand(1,10);
S.Y = rand(1,10);
S.Z = rand(1,10)

%
% Plot the arrays. Return an array of chart line objects from the plot function and use them to add different markers to each set of data points. structfun can return arrays of any data type, so long as objects of that data type can be concatenated.

figure
hold on
p = structfun(@plot,S);
p(1).Marker = 'o';
p(2).Marker = '+';
p(3).Marker = 's';
hold off

% Copyright 2012 The MathWorks, Inc.