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. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

copyobj (any object)

Copy SimBiology object and its children


copiedObj = copyobj(Obj, parentObj)
copiedObj = copyobj(modelObj)


ObjCompartment, configuration set, event, kinetic law, model, parameter, reaction, rule, species, RepeatDose, ScheduleDose, or variant object.


Abstract kinetic law objects cannot be copied using copyobj.


If copiedObj is...parentObj must be...
configuration set, event, reaction, rule, RepeatDose, ScheduleDose, or variant objectmodel object
compartment objectcompartment or model object
species objectcompartment object
parameter objectmodel or kinetic law object
kinetic law objectreaction object
model object sbioroot

modelObjModel object to be copied.
copiedObjOutput returned by the copyobj method with the parent set as specified in input argument (parentObj).


copiedObj = copyobj(Obj, parentObj) makes a copy of a SimBiology® object (Obj) and returns a pointer to the copy (copiedObj). In the copied object (copiedObj), this method assigns a value (parentObj) to the property Parent.

copiedObj = copyobj(modelObj) makes a copy of a model object (modelObj) and returns the copy (copiedObj). In the copied model object (copiedObj), this method assigns the root object to the property Parent.


When the copyobj method copies a model, it resets the StatesToLog property to the default value. Similarly, the Inputs and Outputs properties are not copied but rather left empty. Thus, when you simulate a copied model you see results for the default states, unless you manually update these properties.


Create a reaction object separate from a model object, and then add it to a model.

  1. Create a model object and add a reaction object.

    modelObj1 = sbiomodel('cell');
    reactionObj = addreaction(modelObj1, 'a -> b');
  2. Create a copy of the reaction object and assign it to another model object.

    modelObj2 = sbiomodel('cell2');
    reactionObjCopy = copyobj(reactionObj, modelObj2);
    SimBiology Reaction Array
    Index:    Reaction:
     1         a -> b

Introduced in R2006a