Main Content


Get active choice on variant component



choice = getActiveChoice(variantComponent) finds which choice is active for the variant component.


collapse all

Create a model, get the root architecture, create one variant component, add two choices for the variant component, set the active choice, and get the active choice.

model = systemcomposer.createModel("archModel");
arch = get(model,"Architecture");
variant = addVariantComponent(arch,"Component1");
compList = addChoice(variant,["Choice1","Choice2"]);
comp = getActiveChoice(variant)
comp = 
  Component with properties:

     IsAdapterComponent: 0
           Architecture: [1x1 systemcomposer.arch.Architecture]
                   Name: 'Choice2'
                 Parent: [1x1 systemcomposer.arch.Architecture]
                  Ports: [0x0 systemcomposer.arch.ComponentPort]
             OwnedPorts: [0x0 systemcomposer.arch.ComponentPort]
      OwnedArchitecture: [1x1 systemcomposer.arch.Architecture]
             Parameters: [0x0 systemcomposer.arch.Parameter]
               Position: [15 15 65 76]
                  Model: [1x1 systemcomposer.arch.Model]
         SimulinkHandle: 223.0022
    SimulinkModelHandle: 152.0049
                   UUID: '8e9dd43d-ca00-4b9d-95c9-a12613380670'
            ExternalUID: ''

Input Arguments

collapse all

Variant component, specified as a systemcomposer.arch.VariantComponent object.

Output Arguments

collapse all

Chosen variant, returned as a systemcomposer.arch.Component object.

More About

collapse all


TermDefinitionApplicationMore Information

A variant is one of many structural or behavioral choices in a variant component.

Use variants to quickly swap different architectural designs for a component while performing analysis.

Create Variants
variant control

A variant control is a string that controls the active variant choice.

Set the variant control programmatically to control which variant is active.

Set Variant Control Condition

Version History

Introduced in R2019a