Main Content

getvariant (model)

Get variant from model

Syntax

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

Arguments

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.

Description

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.

Note

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.

Examples

  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');

Version History

Introduced in R2007b