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

    %% Add an Infusion Dose
% This example shows how to add a constant-rate infusion dose to
% a one-compartment model.

% Copyright 2015 The MathWorks, Inc.


%% Background
% Suppose you have a one-compartment model with a species named |drug| that
% represents the total amount of drug in the body. The drug is removed
% from the body via the first-order elimination represented by the reaction
% |drug -> null|, with the elimination rate constant |ke|. In other words,
% the drug concentration versus the time profile follows the monoexponential
% decline ${C_t} = {C_0}{e^{ - {k_e}t}}$, where $C_t$ is the drug
% concentration at time t, $C_0$ is the initial concentration, and |ke| is
% the elimination rate constant. This example shows how to set up such
% a one-compartment model and add an infusion dose at a constant rate of 10
% mg/hour for the total dose amount of 250 mg.
%% Create a One-compartment Model
% Create a SimBiology model named |onecomp|.
m1 = sbiomodel('onecomp');
%%
% Define the elimination of the drug from the system by adding a reaction
% |drug -> null| to the model.
r1 = addreaction(m1,'drug -> null');
%%
% The species |drug| is automatically created and added to the
% compartment. The |null| species is a reserved species that acts as a sink
% in this reaction.
%%
% Add a mass action kinetic law to the reaction. This kinetic law defines
% the drug elimination to follow the first-order kinetics.
k1 = addkineticlaw(r1,'MassAction');
%%
% Define the elimination rate parameter |ke| and add it to the kinetic law.
p1 = addparameter(k1,'ke','Value',1.0,'ValueUnits','1/hour');
%%
% Specify the rate parameter |ke| as the forward rate parameter of the
% reaction by setting the |ParameterVariableNames| property of kinetic law
% object |k1|. This allows SimBiology to determine the reaction rate for |drug ->
% null| reaction.
k1.ParameterVariableNames = 'ke';
%% Set up an Infusion Dose
% Add a dose object to the model using the |adddose| method. Specify the
% amount of the dose (|Amount|), the dose target (|TargetName|), and the
% infusion rate (|Rate|). You also need to set the |Active| property of the
% dose object to |true| so that the dose is applied to the model during
% simulation.
d1 = adddose(m1,'InfusionDose');
d1.Amount = 250;
d1.TargetName = 'drug';
d1.Rate = 10;
d1.RateUnits = 'milligram/hour';
d1.Active = true;
%% Simulate the Model
% Change the simulation stop time to 48 hours to see the complete time
% course. 
cs = getconfigset(m1);
cs.StopTime = 48;
cs.TimeUnits = 'hour';
sd = sbiosimulate(m1);
%% Plot results
% Plot the concentration versus the time profile of the drug in the
% system.
sbioplot(sd);