This is machine translation

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

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

getvariant (model)

Get variant from model


variantObj = getvariant(modelObj)
variantObj = getvariant(modelObj, 'NameValue')


variantObjVariant object returned by the getvariant method.
modelObjModel object from which to get the variant.
'NameValue'Name of the variant to get from the model object modelObj.


variantObj = getvariant(modelObj) returns SimBiology® variant objects contained by the SimBiology model object modelObj to variantObj.

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

variantObj = getvariant(modelObj, 'NameValue') returns the SimBiology variant object with the name NameValue, contained by the SimBiology model object, modelObj.

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 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 several variants.

    modelObj = sbiomodel('mymodel');
    variantObj1 = addvariant(modelObj, 'v1');
    variantObj2 = addvariant(modelObj, 'v2');
  2. Get all variants in the model.

    vObjs = getvariant(modelObj)  
    SimBiology Variant Array
       Index:  Name:             Active:
       1       v1                false
       2       v2                false
  3. Get the variant object named 'v2' from the model.

    vObjv2 = getvariant(modelObj, 'v2');

Introduced in R2007b

Was this topic helpful?