%% Find a steady state of a simple gene regulation model
% This example shows how to find a steady state of a simple gene regulation model, where the protein product from translation controls transcription.
% Load the sample SimBiology project containing the model, m1. The model has five reactions and four species.

sbioloadproject('gene_reg.sbproj','m1')

%
% Display the model reactions.

m1.Reactions

%
% A steady state calculation attempts to find the steady state values of non-constant quantities. To find out which model quantities are non-constant in this model, use sbioselect.

sbioselect(m1,'Where','Constant*','==',false)

% There are four species that are not constant, and the initial amounts of three of them are set to zero.
%
% Use sbiosteadystate to find the steady state values for those non-constant species.

[success,variantOut] = sbiosteadystate(m1)

% The initial amounts of all species of the model have been set to the steady-state values. DNA is a conserved species since the total of DNA and DNA_protein is equal to 50.
%
% You can also use a variant to store alternate initial amounts and use them during the steady state calculation. For instance, you could set the initial amount of DNA to 100 molecules instead of 50.

variantIn = sbiovariant('v1');
addcontent(variantIn,{'species','DNA','InitialAmount',100});
[success2,variantOut2,m2] = sbiosteadystate(m1,variantIn)

%
% Since the algorithm has found a steady state, the third output m2 is the steady state model, where the values of non-constant quantities have been set to steady state values. In this example, the initial amounts of all four species have been updated to steady state values.

m2.Species

% Copyright 2012 The MathWorks, Inc.