Main Content

addcompartment (model, compartment)

Create compartment object

Syntax

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

Arguments

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.

Description

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
copyobjCopy SimBiology object and its children
deleteDelete SimBiology object
displayDisplay summary of SimBiology object
findUsagesFind out how a species, parameter, or compartment is used in a model
getGet SimBiology object properties
moveMove SimBiology compartment object to new owner
renameRename SimBiology model component and update expressions
reorder (model, compartment, kinetic law)Reorder component lists
setSet SimBiology object properties

Property Summary

Properties for compartment objects

CapacityCompartment capacity
CapacityUnitsCompartment capacity units
CompartmentsArray of compartments in model or compartment
Constant Specify variable or constant species amount, parameter value, or compartment capacity
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
Units Units for species amount, parameter value, compartment capacity, observable expression
UserDataSpecify data to associate with object
ValueValue of species, compartment, or parameter object

Examples

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.

model.Compartments
ans = 
   SimBiology Compartment Array

   Index:    Name:         Value:    Units:
   1         Central       2         liter 
   2         Peripheral    1         liter 

Version History

Introduced in R2007b

expand all