This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materials including this page, select Japan from the country navigator on the bottom of this page.

addcompartment (model, compartment)

Create compartment object


compartmentObj = addcompartment(modelObj, 'NameValue')
compartmentObj = addcompartment(owningCompObj, 'NameValue')
compartmentObj = addcompartment(modelObj, 'NameValue', CapacityValue)
compartmentObj = addcompartment(...'PropertyName', PropertyValue...)


modelObjModel object
owningCompObjCompartment object that contains the newly created compartment object.
NameValueName for a compartment object. Enter a character vector unique to the model object.

For information on naming compartments, see Name.

CapacityValueCapacity value for the compartment object. Enter double. Positive real number, default = 1.
PropertyNameEnter the name of a valid property. Valid property names are listed in Property Summary.
PropertyValueEnter the value for the property specified in PropertyName. Valid property values are listed on each property reference page.


compartmentObj = addcompartment(modelObj, 'NameValue') creates a compartment object and returns the compartment object (compartmentObj). In the compartment object, this method assigns a value (NameValue) to the property Name, and assigns the model object (modelObj) to the property Parent. In the model object, this method assigns the compartment object to the property Compartments.

compartmentObj = addcompartment(owningCompObj, 'NameValue') in addition to the above, adds the newly created compartment within a compartment object (owningCompObj), and assigns this compartment object (owningCompObj) to the Owner property of the newly created compartment object (compartmentObj). The parent model is the model that contains the owning compartment (owningCompObj).

compartmentObj = addcompartment(modelObj, 'NameValue', CapacityValue), in addition to the above, this method assigns capacity (CapacityValue) for the compartment.

If you define a reaction within a model object (modelObj) 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 the format CompartmentName.SpeciesName.

compartmentObj = addcompartment(...'PropertyName', PropertyValue...) defines optional properties. Property Summary lists the properties. The Owner property is one exception; you cannot set the Owner property in the addcompartment syntax because, addcompartment requires the owning model or compartment to be specified as the first argument and uses this information to set the Owner property.

Method Summary

Methods for compartment objects

addcompartment (model, compartment)Create compartment object
addspecies (model, compartment)Create species object and add to compartment object within model object
copyobj (any object)Copy SimBiology object and its children
delete (any object)Delete SimBiology object
display (any object)Display summary of SimBiology object
findUsages (species, parameter, compartment)Find out how a species, parameter, or compartment is used in a model
get (any object)Get object properties
rename (compartment, parameter, species, reaction)Rename object and update expressions
reorder (model, compartment, kinetic law)Reorder component lists
set (any object)Set object properties

Property Summary

Properties for compartment objects

CapacityCompartment capacity
CapacityUnitsCompartment capacity units
CompartmentsArray of compartments in model or compartment
ConstantCapacity Specify variable or constant compartment capacity
NameSpecify name of object
NotesHTML text describing SimBiology object
OwnerOwning compartment
ParentIndicate parent object
SpeciesArray of species in compartment object
TagSpecify label for SimBiology object
TypeDisplay SimBiology object type
UserDataSpecify data to associate with object


collapse all

This example shows how to add compartments to a SimBiology model.

Create a SimBiology model which is named m1.

model = sbiomodel('m1');

Add two compartments to the model, which are named as Central and Peripheral respectively.

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.

   SimBiology Compartment Array

   Index:    Name:         Capacity:    CapacityUnits:
   1         Central       2            liter
   2         Peripheral    1            liter

Introduced in R2007b

Was this topic helpful?