Add dose object to model
|Name of a dose object to construct and add to a model object. |
|Type of dose object to construct and add to a model object.
Enter either |
|Dose object to add to a model object. Created with the constructor |
Before using a dose object in a simulation, use the
to add the dose object to a SimBiology®
object. Then, set the
object property to
a SimBiology RepeatDose object (
DoseName to the property
adds the dose object to a SimBiology model object (
modelObj to the property
either a SimBiology
ScheduleDose object or
adds a SimBiology dose object (
) to a
SimBiology model object
copies the dose object to a second dose object (
modelObj to the property
Active property of
is set to
false by default.
Alternatively, you can create a dose object using
sbiodose as a standalone dose object,
which you can apply to different models. For details, see Creating Doses Programmatically.
Add an Infusion Dose
This example shows how to add a constant-rate infusion dose to a one-compartment model.
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 , where is the drug concentration at time t, 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
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');
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 the concentration versus the time profile of the drug in the system.
Version HistoryIntroduced in R2010a
R2022b: Having duplicate model component names issues a warning
SimBiology issues a warning if multiple model components (model, compartment, species, parameter, reaction, rule, event, observable, dose, and variant) have the same name. In a future release, within a single model, these components will be required to have unique names even when they are of different types with the following two exceptions:
Species in different compartments can have the same name.
Parameters can have the same name if they are scoped to different parents. Specifically, you can use the same name for a model-scoped parameter and reaction-scoped parameters, where each reaction-scoped parameter belongs to a different reaction.
The purpose of this naming restriction is to ensure that every model component can be unambiguously referenced by its unique name within a model. For details on how to reference model component names in expressions, see Guidelines for Referencing Names in Expressions.
To disambiguate duplicate names from your model, use the
updateDuplicateNamesfunction at the command line. The function takes in a SimBiology model as an input and updates the component names as necessary. You can also specify optional outputs, such as a logical flag to check whether any update occurred, a list of model changes, and a copy of the original model before any updates were made.
updateDuplicateNamesfunction disambiguates the duplicate names by adding a suffix
"_N", where N is the first positive integer that results in a unique name. If there is an existing suffix, N will be incremented from that suffix. For example, if there are two model components named x_3, the function updates one of the names to x_4. If the existing suffix has leading zeros, the function omits the zeros in the new name. For instance, if x_003 is a duplicate name, it gets renamed to x_4. However, the function assumes that names with leading zeros and without leading zeros are different. For instance, x_005 and x_5 are considered to be different names.
R2022a: Having duplicate model component names will not be allowed in a future release
SimBiology will not allow you to have duplicate names for model components within a model.
model object |
RepeatDose object |