www.gusucode.com > simbio 案例源码程序 matlab代码 > simbio/CreateARateRuleForAConstantRateOfChangeExample.m

    %% Create a Rate Rule for a Constant Rate of Change
% This example shows how to increase the amount or
% concentration of a species by a constant value using the zero-order rate
% rule. For example, suppose species |x| increases by a constant rate |k|.
% The rate of change is:
%
% $$dx/dt=k$$
%
% Set the initial amount of species |x| to 2, and the value of parameter
% |k| to 1. Use the following commands to set up a SimBiology model
% accordingly and simulate it.

% Copyright 2015 The MathWorks, Inc.


m = sbiomodel('m');
c = addcompartment(m,'comp');
s = addspecies(m,'x','InitialAmount',2);
p = addparameter(m,'k','Value',1);
r = addrule(m,'x = k','RuleType','rate');
[t,sd,species] = sbiosimulate(m);
plot(t,sd);
legend(species)
xlabel('Time');
ylabel('Species Amount');

%% 
% Alternatively, you could model a constant increase in a species using the
% Mass Action reaction |null| -> |x| with the forward rate constant |k|.
clear
m = sbiomodel('m');
c = addcompartment(m,'comp');
s = addspecies(m,'x','InitialAmount',2);
r = addreaction(m,'null -> x');
kl = addkineticlaw(r,'MassAction');
p = addparameter(kl,'k','Value',1);
kl.ParameterVariableNames = 'k';
[t,sd,species] = sbiosimulate(m);
plot(t,sd);
legend(species)
xlabel('Time');
ylabel('Species Amount');