%% Create and Simulate the Yeast G Protein Cycle
%% Load the model

sbioloadproject gprotein

%
%% Configure Simulation Settings

csObj = getconfigset(m1);
csObj.SolverType = 'ode15s';
csObj.StopTime   = 500;

%
%% Specify to log simulation results of all species

csObj.RuntimeOptions.StatesToLog = 'all';

%
%% Add an event to the model

speciesObj = sbioselect(m1,'Type','species','Name','L');
speciesObj.InitialAmount = 0;
evt = addevent(m1,'time >= 100','L = 6.022E17');

%
%% Simulate the model

[t,x,names] = sbiosimulate(m1);

%
%% Plot the results

plot(t,x);
legend(names)
xlabel('Time');
ylabel('Amount');

%
%% Plot without Species L data

figure
plot(t,x(:,[1:4 6:8]));
legend(names{[1:4 6:8]});
xlabel('Time');
ylabel('Amount');

%
%% Store Results in a SimData Object

simdata     = sbiosimulate(m1);
sbioplot(simdata);

%
%% Plot SimData without Species L Data

simdata_noL = selectbyname(simdata, {'Ga','G','Gd','GaFrac','RL','R'});
sbioplot(simdata_noL);

% Copyright 2015 The MathWorks, Inc.