Main Content

Variant Terminology

Simulink® variant terminology helps you to understand various parameters and terms.

Variant TerminologyDescription
Variant Subsystem, Variant ModelContains one or more choices where each choice is a Subsystem or Model block.
Variant SourceProvides variation on the source of a signal.
Variant SinkProvides variation on the sink (destination) of a signal.
Variant ModelVariant Subsystem block containing Model block as variant choices.
Active choiceVariant choice associated with a variant control that evaluates to true.
Variant control expression

expression, label or sim codegen switching for modeling variant blocks and variant parameters.

Variant control variableMATLAB® variable, Simulink.Variant object, or a Simulink.Parameter object.
Variant objectContainer of variant control expression.
Variant Manager Central tool that allows you to manage various variation points that are modeled using variant blocks in a system model.
Variant Reducer Reduces variant models to simplified, standalone model depending on the selected variant configurations.
Variant Configuration, Variant Configuration data object

A variant configuration consists of a named set of variant control variables, their values, and configurations to be used by referenced models. It can be used to activate a variation of a Simulink model.

A variant configuration data object (instance of the Simulink.VariantConfigurationData class) associated with a model stores:

  • Collection of all variant configurations for the model.

  • Set of constraints that must be satisfied by the model for all variant configurations.

  • Default configuration for the model.

You can create new variant configurations and group them into a variant configuration data object from Variant Manager or programmatically using the Simulink.VariantConfigurationData class.

To associate the variant configuration data object to a model, use the Export variant configuration data object functionality in Variant Manager, or use the VariantConfigurationObject parameter. Example:

variantConfig = Simulink.VariantConfigurationData;
set_param(model, 'VariantConfigurationObject',...
'variantConfig');

Command Line Parameters

Variant Subsystem Parameters

Parameter nameDescription
Variant

Used to check if the subsystem is a Variant Subsystem block. Returns on if the subsystem is a Variant Subsystem block, else it returns off. Example: get_param(gcb, 'Variant')

This is a read-only parameter.

VariantChoices

Gets the list of variant choices in a Variant Subsystem block. Example: get_param(gcb, 'VariantChoices');

Returns a 1-by-N struct array with fields:

Name: Name of the variant control

BlockName: Block path name

This is a read-only parameter.

VariantControl

Subsystem block and Model block parameter, which applies to a choice block of a Variant Subsystem block and returns the variant control for the choice block.

  • get_param behavior: Returns variant controls for choice block of a Variant Subsystem block. Example: get_param(gcb, 'VariantControl')

  • set_param behavior: Sets variant control for current block. Example: set_param(gcb, 'VariantControl', 'A==1')

VariantControlMode

Specifies the mode for modeling Variant blocks, which can be either expression or label or sim codegen switching.

  • get_param behavior:

    Returns the mode set for modeling Variant blocks. Example: get_param(gcb, 'VariantControlMode')

  • set_param behavior:

    Sets the mode for modeling Variant blocks. Example: set_param(gcb, 'VariantControlMode', 'Label')

LabelModeActiveChoice

Returns the variant control label of the selected choice for the Variant Subsystem block when VariantControlMode is specified as label . If VariantControlMode is specified as expression, this parameter returns empty ('').

  • get_param behavior:

    Returns the variant control label of the selected choice for the Variant Subsystem when VariantControlMode is set to label. If VariantControlMode is set to expression, this parameter returns empty ('').

  • set_param behavior:

    When VariantControlMode is specified as expression, set_param makes the label selected as the active choice. When VariantControlMode is label, set_param switches between specified labels.

TreatAsGroupedWhenPropagatingVariantConditions

Returns on if the Subsystem is treated as a group when propagating variant conditions else returns off.

  • get_param behavior:

    Indicates if the subsystem is treated as a group when propagating Variant conditions or not by returning on or off. Example: get_param(gcb, 'TreatAsGroupedWhenPropagatingVariantConditions')

  • set_param behavior:

    Enables or disables treating subsystem as a group when propagating variant conditions. Example: set_param(gcb, 'TreatAsGroupedWhenPropagatingVariantConditions', 'on')

GeneratePreprocessorConditionals

Indicates if all the choices are to be analyzed and preprocessor conditionals to be generated by returning on or off.

  • get_param behavior:

    Indicates if all the choices are to be analyzed and preprocessor conditionals be generated by returning on or off. Example: get_param(gcb, 'GeneratePreprocessorConditionals')

  • set_param behavior:

    Enables or disables analyzing all the choices and generating preprocessor conditionals. Example: set_param(gcb, 'GeneratePreprocessorConditionals', 'on')

Note

Use the Variant activation time parameter instead.

CompiledActiveChoiceControl

Returns the variant control corresponding to the active choice of the Variant Subsystem block and returns empty (' ') when no choice is active. When the block is commented or is inside a commented subsystem, this parameter returns empty(' '). Example: get_param(gcb, 'CompiledActiveChoiceControl').

This is a read-only parameter.

CompiledActiveChoiceBlock

Returns the full block path name of the active Variant Subsystem block choice and returns empty (' ') when no choice is active. When the block is commented or is inside a commented Subsystem, the value is returned as empty(' '). Example: get_param(gcb, 'CompiledActiveChoiceBlock').

This is a read-only parameter.

CompiledVariantInfo

Block parameter that indicates the variant activeness of a block after model compilation. Returns a structure with three fields, with values set to on or off:

  • IsActive: Value is on if the block is active in simulation.

  • IsInCodegen: Value is on if the block is part of generated code.

  • IsInStartup: Value is on if the block is active or can become active in simulation (the propagated value of Variant activation time on the block is startup) after model compilation.

For an example, see Identify Variant Activeness of a Block After Model Compilation.

This is a read-only parameter.

PropagateVariantConditions

Indicates if conditions on ports inside the Variant Subsystem block are to be propagated outside the block.

  • get_param behavior:

    Indicates if conditions on ports inside the Variant Subsystem block are to be propagated outside the block.

  • set_param behavior:

    Enables or disables propagating conditions outside Variant Subsystem block. Example: set_param(gcb, 'PropagateVariantConditions','on')

AllowZeroVariantControls

Indicates if the Variant Subsystem block is allowed to have no active choices.

  • get_param behavior:

    Indicates if the Variant Subsystem block is allowed to have no active choices.

  • set_param behavior:

    Enables or disables having active choices in Variant Subsystem block. Example: set_param(gcb, 'AllowZeroVariantControls','on')

Variant activation time

Determines if Simulink sets the active choice of a Variant Subsystem block during update diagram or code compile.

  • get_param behavior:

    Returns the Variant Activation Time of a Variant Subsystem block. This parameter can be set to update diagram, update diagram analyze all choices, or code compile.

    Example: get_param(gcb, 'VariantActivationTime')

  • set_param behavior:

    • When you set the Variant control mode to expression, this parameter can be set to update diagram, update diagram analyze all choices, or code compile.

    • When you set the Variant control mode to sim codegen switching, this parameter can be set to either update diagram or update diagram analyze all choices. The code compile option becomes unavailable.

    Example: set_param(gcb,'VariantActivationTime', 'update diagram')

Note

The get_param and set_param behavior of VariantActivationTime parameter with the code compile option is equivalent to that of the parameter GeneratePreprocessorConditionals.

Variant Source and Variant Sink Parameters

Parameter nameDescription
VariantControls

Returns a 1-by-N cell array of variant control expressions corresponding to each of the N ports of the Variant Source or Variant Sink blocks.

  • get_param behavior:

    Returns a cell array of variant control expressions corresponding to each ports of the Variant Source or Variant Sink blocks. Example: get_param(gcb, 'VariantControls')

  • set_param behavior:

    Sets the cell array of Variant control expressions corresponding to each of ports of Variant Source or Variant Sink blocks. Example: set_param(gcb, 'VariantControls', ('{A==1}, '4'))

VariantControlMode

Specifies the mode for modeling variant blocks, which can be either Expression or Label.

  • get_param behavior:

    Returns the mode set for modeling Variant blocks. Example: get_param(gcb, 'VariantControlMode')

  • set_param behavior:

    Sets the mode for modeling Variant blocks. Example: set_param(gcb, 'VariantControlMode', 'Label')

LabelModeActiveChoice

Returns the variant control label of the selected choice for Variant Source or Variant Sink block when VariantControlMode is specified as Label. If VariantControlMode is specified as Expression, this parameter returns empty ('').

  • get_param behavior:

    Returns the variant control label of the selected choice for the Variant Subsystem when VariantControlMode is set to Label. If VariantControlMode is set to Expression, this parameter returns empty ('').

  • set_param behavior:

    When VariantControlMode is specified as Expression, set_param makes the label selected as the active choice. When VariantControlMode is Label, set_param switches between specified labels.

GeneratePreprocessorConditionals

Indicates if all the choices are to be analyzed and preprocessor conditionals to be generated by returning on or off.

  • get_param behavior:

    Indicates if all the choices are to be analyzed and preprocessor conditionals to be generated by returning on or off. Example: get_param(gcb, 'GeneratePreprocessorConditionals')

  • set_param behavior:

    Enables or disables analyzing all the choices and generating preprocessor conditionals. Example: set_param(gcb, 'GeneratePreprocessorConditionals', 'on')

Note

Use the Variant activation time parameter instead.

ShowConditionOnBlock

Indicates if the VariantControlExpression is to be displayed on the block by returning on or off.

  • get_param behavior:

    Indicates if the VariantControlExpression is to be displayed on the block or not.

  • set_param behavior:

    Enables or disables the displaying of VariantControlExpression on the block. Example: set_param(gcb, 'ShowConditionOnBlock','on')

AllowZeroVariantControls

Indicates if the block is allowed to have no active ports by returning on or off.

  • get_param behavior:

    Indicates if the Variant Source or Variant Sink block is allowed to have no active choices.

  • set_param behavior:

    Enables or disables having active choices in Variant Source or Variant Sink block. Example: set_param(gcb, 'AllowZeroVariantControls','on')

CompiledActiveVariantControl

Returns the variant control corresponding to the active port from the last compilation instance. If no port is active, returns empty (' '). If the block is commented or inside a commented Subsystem or inside an inactive choice of a Variant Subsystem block, the value is not computed and returns empty (' '). Example: get_param(gcb, 'CompiledActiveVariantControl')

This is a read-only parameter.

CompiledActiveVariantPort

Returns the "index" of the active port from the last compilation instance or returns -1 when no port is active. If the block is commented or inside a commented Subsystem or inside an inactive choice of a Variant Subsystem block (with generate preprocessor conditionals Off), the value is not computed, and returns empty (' '). Example: get_param(gcb, 'CompiledActiveVariantPort')

This is a read-only parameter.

Related Examples

More About