%% Estimate Yeast G Protein Model Parameter
% 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]';

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

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

%
% 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';

%
% 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 plot the model simulation results using the estimated parameter value. You can either rerun the sbiofit function and specify to return the optional second output argument, which contains simulation results, or use the fitted method to retrieve the results without rerunning sbiofit.

[yfit,paramEstim] = fitted(fitResult);

%
% Plot the simulation results.

sbioplot(yfit);

% Copyright 2012 The MathWorks, Inc.