主要内容

addmodel

R2026b

Add submodel to model

Since R2026b

Description

addmodel(parentModel,name) adds an empty submodel with the specified name to parentModel. To add a copy of an existing model as a submodel instead, use copyobj.

example

subModel = addmodel(parentModel,name) also returns the added submodel.

example

Examples

collapse all

Create a parent model and add submodels to build a model hierarchy.

parentModel = sbiomodel("PBPK");

Add submodels representing individual organs.

liverModel = addmodel(parentModel,"Liver submodel");
kidneyModel = addmodel(parentModel,"Kidney submodel");
brainModel = addmodel(parentModel,"Brain submodel");

Verify that the submodels appear in the parent model.

parentModel.Models
ans = 
   SimBiology Model Array

   Index:    Name:              ParentModel:
   1         Liver submodel     PBPK        
   2         Kidney submodel    PBPK        
   3         Brain submodel     PBPK        

Add compartments and species to a submodel.

addcompartment(liverModel,"Tissue");
addspecies(liverModel.Compartments(1),"Drug");

The fully qualified name reflects the position of the submodel in the model hierarchy.

liverModel.FullyQualifiedName
ans = 
'PBPK.[Liver submodel]'

Add a submodel inside another submodel to create a deeper hierarchy.

stomachModel = addmodel(parentModel,"GI Tract");
smallIntestineModel = addmodel(stomachModel,"Small Intestine");
smallIntestineModel.FullyQualifiedName
ans = 
'PBPK.[GI Tract].[Small Intestine]'

Input Arguments

collapse all

Model to add the submodel to, specified as a SimBiology.Model object. The submodel becomes a direct child of parentModel and appears in its Models property.

Name of the new submodel, specified as a string scalar or character vector. The name must be unique across all model components in the parentModel.

Data Types: char | string

Output Arguments

collapse all

New submodel, returned as a SimBiology.Model object. The submodel is empty (no compartments, species, parameters, reactions, or rules) and its FullyQualifiedName property reflects its position in the model hierarchy.

Version History

Introduced in R2026b