Main Content

Variant Terminology

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

Variant TerminologyDescription
Variant SubsystemContains 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. See Variant Subsystem.
Active choiceVariant choice associated with a variant control that evaluates to true.
Variant control mode

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

Variant control variableMATLAB® variable, Simulink.VariantExpression object, or a Simulink.Parameter object. See Types of Variant Control Variables (Operands) in Variant Blocks.
Variant objectContainer of variant control expression. See Simulink.VariantExpression.
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

This section lists the command line parameters you can use to control a Variant Subsystem block during simulation or code generation.

You can add variant choices to the Variant Subsystem block using the add_block command:

add_block('simulink/Ports & Subsystems/BlockName', ...
	[ModelName '/VariantSubsystemChoicePath'], ...
	VariantControl='VariantControlName');
Here, BlockName is the block to add as a variant choice to the Variant Subsystem block at path VariantSubsystemChoicePath in the model ModelName. VariantControlName is the name of the variant control for the newly added variant choice.

For example, to add the Subsystem block named Discrete as a variant choice to the Controller subsystem in the slexVariantSubsystemsAdaptiveInterface model, use this command. Specify the variant control as V == 3.

add_block('simulink/Ports & Subsystems/Subsystem', ...
    'slexVariantSubsystemsAdaptiveInterface/Controller/Discrete', ...
    VariantControl='V == 3');

Note

If you do not specify a variant control, a variant block with an empty variant control is created. You are then required to specify the variant control parameter in the subsequent line of code.

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

See Variant control mode.

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.

See Label mode active choice.

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

See Propagate Variant Conditions to Define Variant Regions in Virtual and Nonvirtual Subsystems.

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. If Allow zero active variant controls is off and no choice is active, it returns the first variant choice as the active choice, since having no active choice is not allowed. If Allow zero active variant controls is on and no choice is active, it returns empty (' '). 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.

CompiledVariantActivationTime

Returns the variant activation time of the block after model compilation. Before the model is compiled, this parameter returns update diagram activation time. Example: get_param(gcb,'CompiledVariantActivationTime')

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

See Propagate conditions outside of variant subsystem.

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

See Allow zero active variant controls.

VariantActivationTime

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.

See Variant activation time.

VariantControlVariable

Specifies the variant control variable of a Variant Assembly Subsystem block that is in expression mode.

  • get_param behavior:

    Returns the variant control variable of a Variant Assembly Subsystem block.

    Example: get_param(gcb, 'VariantControlVariable')

  • set_param behavior:

    Sets the variant control variable of a Variant Assembly Subsystem block.

    Example: set_param(gcb,'VariantControlVariable', 'variantCtrlVar')

See Variant control variable.

VariantChoicesEnumeration

Specifies the variant choices of a Variant Assembly Subsystem block that is in expression mode.

  • get_param behavior:

    Returns the enumeration class name that contains the variant choice names as its members.

    Example: get_param(gcb, 'VariantChoicesEnumeration')

  • set_param behavior:

    Sets the variant choices using the enumeration class.

    Example: set_param(gcb,'VariantChoicesEnumeration', 'controllerEnum')

See Variant choices enumeration.

VariantChoicesSpecifier

Specifies the variant choices of a Variant Assembly Subsystem block that is in label mode.

  • get_param behavior:

    Returns the specifier that evaluates to the variant choice names.

    Example: get_param(gcb, 'VariantChoicesSpecifier')

  • set_param behavior:

    Sets the variant choices using the specifier.

    Example: set_param(gcb,'VariantChoicesSpecifier',"{'ControllersList/*', 'ControllersList/*/*'}")

See Variant choices specifier.

AllowFlexibleInterface

Indicates if the Variant Subsystem block has a flexible interface.

  • get_param behavior:

    Indicates if the Variant Subsystem has a flexible interface.

  • set_param behavior:

    Enables or disables the flexible interface of the Variant Subsystem block.

See Allow flexible interface.

Variant Source and Variant Sink Parameters

This section lists the command line parameters you can use to control Variant Source and Variant Sink blocks during simulation or code generation.

You can add these blocks using the add_block command:

add_block('simulink/Signal Routing/BlockName', ...
	[ModelName '/VariantBlockPath']
Here, BlockName is the variant block to be added to VariantBlockPath in model ModelName.

For example, to add the Variant Source block named Discrete in the slexVariantSourceAndSink model, use this command. Specify the variant control as V == 3.

add_block('simulink/Signal Routing/Subsystem', ...
    'slexVariantSourceAndSink/Discrete', ...
    VariantControl='V == 3');

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

See Variant control mode.

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.

See Label mode active choice.

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

See Show variant condition on block.

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

See Allow zero active variant controls.

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.

CompiledVariantActivationTime

Returns the variant activation time of the block after model compilation. Before the model is compiled, this parameter returns update diagram activation time. Example: get_param(gcb,'CompiledVariantActivationTime')

This is a read-only parameter.

OutputFunctionCall

Indicates if the Variant Source or Variant Sink blocks are allowed to output function-call signals.

  • get_param behavior:

    Indicates if the variant block is allowed to output function-call signals.

    Example: get_param(gcb, 'OutputFunctionCall')

  • set_param behavior:

    Enables or disables the ability of the variant block to output function-call signals. Example: set_param(gcb, 'OutputFunctionCall','on')

See Output function call.

Examples

Identify Variant Activeness of a Block After Model Compilation

This example shows the behavior of the CompiledVariantInfo command line parameter. Consider a model with two Variant Subsystem blocks, StartupVSS and UDVSS, with the Variant activation time parameter set to startup and update diagram, respectively. The result of CompiledVariantInfo parameter after model compilation is shown for each variant choice.

  • The active choice in both StartupVSS and UDVSS has IsInStartup set to on because the blocks are active in simulation.

  • The inactive choice in StartupVSS gets the propagated startup variant activation time from its parent, so IsInStartup is on.

  • The inactive choice in UDVSS has the update diagram variant activation time, so IsInStartup is off.

CompiledVariantInfo parameter result for each variant choice

Related Examples

More About