%% Scatter Plot of Parameter Samples and Cost Function Evaluations
% Generally, you use the sdo.scatterPlot(X,Y) syntax with X specifying the samples and Y specifying the cost function value for each sample. Use the sdo.evaluate command to perform the cost function evaluation to generate Y. For this example, obtain 100 samples of the Ac and K parameters of the sdoHydraulicCyclinder model. Calculate the cost function as a function of Ac and K. Create a scatter plot to see the sample and cost function values.
% Load the sdoHydraulicCyclinder model.

load_system('sdoHydraulicCylinder');

%
% Generate 100 samples of the Ac and K parameters.

p = sdo.getParameterFromModel('sdoHydraulicCylinder',{'Ac','K'});
ps = sdo.ParameterSpace(p);
X = sdo.sample(ps,100);

% The first operation obtains the Ac and K parameters as a vector, p. The second operation creates an sdo.ParameterSpace object, ps, that specifies the probability distributions of the parameter samples. The third operation generates 100 samples of each parameter, returned as a Table, X.
%
% Calculate the cost function value table.

Ac_mean = mean(X{:,1});
K_mean = mean(X{:,2});
Y = table(X{:,1}/Ac_mean+X{:,2}/K_mean,'VariableNames',{'y'});

%
% Create a scatter plot of X and Y.

sdo.scatterPlot(X,Y);

% Copyright 2012 The MathWorks, Inc.