This is machine translation

Translated by Microsoft
Mouse over text to see original. Click the button below to return to the English verison of the page.


Array of compartments in model or compartment


Compartments shows you a read-only array of SimBiology® compartment objects in the model object and the compartment object. In the model object, the Compartments property indicates all the compartments in a Model object as a flat list. In the compartment object, the Compartments property indicates other compartments that are referenced within the compartment. The two instances of Compartments are illustrated in Examples.

You can add a compartment object using the method addcompartment.


Applies toObjects: compartment, model
Data typeArray of compartment objects
Data valuesCompartment object. Default is [] (empty).


  1. Create a model object named modelObj.

    modelObj = sbiomodel('cell');
  2. Add two compartments to the model object.

    compartmentObj1 = addcompartment(modelObj, 'nucleus');
    compartmentObj2 = addcompartment(modelObj, 'mitochondrion');
  3. Add a compartment to one of the compartment objects.

    compartmentObj3 = addcompartment(compartmentObj2, 'matrix');
  4. Display the Compartments property in the model object.

    get(modelObj, 'Compartments')
    SimBiology Compartment Array
       Index:    Name:            Capacity:    CapacityUnits:
       1         nucleus          1            
       2         mitochondrion    1            
       3         matrix           1  
  5. Display the Compartments property in the compartment object.

    get(compartmentObj2, 'Compartments')
    SimBiology Compartment - matrix 
       Compartment Components:
         Capacity:          1
         Compartments:      0
         ConstantCapacity:  true
         Owner:             mitochondrion
         Species:           0
Was this topic helpful?