addcompartment (model, compartment)
Create compartment object
|Compartment object that contains the newly created compartment object.
|Name for a compartment object. Enter a character vector unique
to the model object.
For information on naming compartments,
|Capacity value for the compartment object. Enter
Positive real number, default =
|Enter the name of a valid property. Valid property names are listed in Property Summary.
|Enter the value for the property specified in
Valid property values are listed on each property reference page.
a compartment object and returns the compartment object (
In the compartment object, this method assigns a value (
to the property
Name, and assigns the
model object (
to the property
Parent. In the model object, this
method assigns the compartment object to the property
in addition to the above, adds the newly created compartment within
a compartment object (
and assigns this compartment object (
Owner property of the newly created compartment
The parent model is the model that contains the owning compartment
in addition to the above, this method assigns capacity
If you define a reaction within a model object (
that does not contain any compartments, the process of adding a reaction
generates a default compartment object and assigns the reaction species
to the compartment. If there is more than one compartment, you must
specify which compartment the species should be assigned to using
Owner property is one exception;
you cannot set the
Owner property in the
addcompartment requires the owning model
or compartment to be specified as the first argument and uses this
information to set the
Methods for compartment objects
|addcompartment (model, compartment)
|Create compartment object
|addspecies (model, compartment)
|Create species object and add to compartment object within model object
|Copy SimBiology object and its children
|Delete SimBiology object
|Display summary of SimBiology object
|Find out how a species, parameter, or compartment is used in a model
|Get SimBiology object properties
|Move SimBiology compartment object to new owner
|Rename SimBiology model component and update expressions
|reorder (model, compartment, kinetic law)
|Reorder component lists
|Set SimBiology object properties
Properties for compartment objects
|Compartment capacity units
|Array of compartments in model or compartment
|Specify variable or constant species amount, parameter value, or compartment capacity
|Specify variable or constant compartment capacity
|Specify name of object
|HTML text describing SimBiology object
|Indicate parent object
|Array of species in compartment object
|Specify label for SimBiology object
|Display SimBiology object type
|Units for species amount, parameter value, compartment capacity, observable expression
|Specify data to associate with object
|Value of species, compartment, or parameter object
This example shows how to add compartments to a SimBiology model.
Create a SimBiology model which is named
model = sbiomodel('m1');
Add two compartments to the model, which are named as
comp1 = addcompartment(model,'Central'); comp2 = addcompartment(model,'Peripheral');
Change the compartment capacities and units.
comp1.Capacity = 2; comp1.CapacityUnits = 'liter'; comp2.Capacity = 1; comp2.CapacityUnits = 'liter';
Display all the compartments of the model.
ans = SimBiology Compartment Array Index: Name: Value: Units: 1 Central 2 liter 2 Peripheral 1 liter
Version HistoryIntroduced in R2007b
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.