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.

addvariant (model)

Add variant to model


variantObj = addvariant(modelObj, 'NameValue')
variantObj2 = addvariant(modelObj, variantObj)


modelObjSpecify the model object to which you want add a variant.
variantObjVariant object to create and add to the model object.
NameValueName of the variant object. NameValue is assigned to the Name property of the variant object.


variantObj = addvariant(modelObj, 'NameValue') creates a SimBiology® variant object (variantObj) with the name NameValue and adds the variant object to the SimBiology model object modelObj. The variant object Parent property is assigned the value of modelObj.

A SimBiology variant object stores alternate values for properties on a SimBiology model. For more information on variants, see Variant object.

variantObj2 = addvariant(modelObj, variantObj) adds a SimBiology variant object (variantObj) to the SimBiology model object and returns another variant object variantObj2. The variant object variantObj2 Parent property is assigned the value of modelObj. The Active property of variantObj2 is set to false by default.

View properties for a variant object with the get command, and modify properties for a variant object with the set command.


Remember to use the addcontent method instead of using the set method on the Content property, because the set method replaces the data in the Content property, whereas addcontent appends the data.

To view the variants stored on a model object, use the getvariant method. To copy a variant object to another model, use copyobj. To remove a variant object from a SimBiology model, use the delete method.


  1. Create a model containing one species.

    modelObj = sbiomodel('mymodel');
    compObj = addcompartment(modelObj, 'comp1');
    speciesObj = addspecies(compObj, 'A');
  2. Add a variant object that varies the InitialAmount property of a species named A.

    variantObj = addvariant(modelObj, 'v1');
    addcontent(variantObj, {'species', 'A', 'InitialAmount', 5});

Introduced in R2007b