%% Evaluate Fitted SimBiology Model
% This example uses the yeast heterotrimeric G protein model and experimental data reported by [1]. For details about the model, see the Background section in Parameter Scanning, Parameter Estimation, and Sensitivity Analysis in the Yeast Heterotrimeric G Protein Cycle.
% Load the G protein model.

sbioloadproject gprotein

%
% Store the experimental data containing the time course for the fraction of active G protein.

time = [0 10 30 60 110 210 300 450 600]';
GaFracExpt = [0 0.35 0.4 0.36 0.39 0.33 0.24 0.17 0.2]';

%
% Map the appropriate model component to the experimental data. In other words, indicate which species in the model corresponds to which response variable in the data. In this example, map the model parameter GaFrac to the experimental data variable GaFracExpt from grpData.

responseMap = 'GaFrac = GaFracExpt';

%
% Create a groupedData object based on the experimental data.

tbl = table(time,GaFracExpt);
grpData = groupedData(tbl);

%
% Use an estimatedInfo object to define the model parameter kGd as a parameter to be estimated.

estimatedParam = estimatedInfo('kGd');

%
% Perform the parameter estimation.

fitResult = sbiofit(m1,grpData,responseMap,estimatedParam);

%
% View the estimated parameter value of kGd.

fitResult.ParameterEstimates

%
% Suppose you want to simulate the fitted model using different output times than those in the training data. You can use the predict method to do so.
% Create a new variable T with different output times.

T = [0;10;50;80;100;150;300;350;400;450;500;550];

%
% Use the predict method to simulate the fitted model on the new time points. No dosing was specified when you first ran sbiofit. Hence, you cannot use any dosing information with the predict method, and an empty array must be specified as the third input argument.

ynew = predict(fitResult,T,[]);

%
% Plot the simulated data with the new output times.

sbioplot(ynew);

% Copyright 2019 The MathWorks, Inc.