Variant Subsystem, Variant Model

Template subsystem containing Subsystem blocks or Model blocks as Variant choices

  • Library:
  • Simulink / Ports & Subsystems

    HDL Coder / Ports & Subsystems

Description

The Variant Subsystem block can have at most one active choice for simulation. The Variant Subsystem block is a template preconfigured to contain two Subsystem blocks to use as Variant Subsystem choices.

A Variant Subsystem block can contain a mixture of Subsystem and Model blocks as Variant systems. This can also include Inport, Outport, and Connection Port blocks. There are no drawn connections inside the Variant Subsystem blocks.

A Variant Subsystem block with Model blocks as choices, is called Variant Model block.

Each Variant system is associated with a Variant control that is created in the global workspace. The Variant control determines which Variant system is active. The Variant control can be a condition expression, a Simulink.Variant object specifying a condition expression, or a default Variant. The Variant control that evaluates to true determines the active Variant.

When you select the Specify output when source is unconnected option in the Outport block that is in a Variant Subsystem block, you can specify a non-ground value as its output.

Note

You must specify the correct data type in the Signal Attributes section of the Outport block dialog box.

Ports

During simulation, Simulink® disables the inactive ports in a Variant Subsystem block.

Input

expand all

Each Subsystem or Model block contained within a Variant Subsystem represents one Variant system. If the inport names on a Variant system are a subset of the inport names used by the Variant Subsystem container block, then Variant system blocks can have different numbers of inports than the Variant Subsystem block has.

Output

expand all

Each Subsystem or Model block contained within a Variant Subsystem represents one Variant system. If the outport names on a Variant system are a subset of the outport names used by the Variant Subsystem block, then Variant system blocks can have different numbers of outports than the Variant Subsystem block has.

Parameters

expand all

To choose the active Variant based on the evaluation of the Variant conditions, use the Expression mode else select Label mode. When you select the Variant control mode as Label, the Label mode active choice option is available. In Label mode, Variant control need not be created in the global workspace. You can select an active Variant choice from Label mode active choice options.

When you select Label mode, the Variant badge indicates the change.

Note

When you promote the Label mode active choice parameter to a mask, the Variant control mode is disabled. While promoting Label mode active choice parameter to a mask in a nested model, ensure that you promote Label mode active choice parameter to the immediate parent Variant Subsystem block mask.

  • If the block is in Expression mode while promoting Label mode active choice parameter to mask, you can change the Variant control mode to Label by changing the promoted Label mode active choice parameter from the Mask dialog box.

  • If the block is in Label mode while promoting Label mode active choice parameter to mask, you cannot change the Variant control mode to Expression mode.

For information about promoting parameters to mask, see Promote Parameter to Mask.

The table has a row for each Variant system contained in the Variant Subsystem. If there are no Variant systems, the table is empty.

You can use buttons to the left of the Variant choices table to modify the elements in the table.

To...Click...
Create and add a new subsystem choice: Place a new Subsystem Variant choice in the table and create a Subsystem block in the Variant Subsystem block diagram.
Create and add a new model variant choice: Place a new Model Variant choice in the table and create a Model block in the Variant Subsystem block.
Create/Edit selected variant object: Create a Simulink.Variant object in the global workspace and open the Simulink.Variant object parameter dialog box to specify the Variant Condition.
Open selected variant choice block: Open the Subsystem block diagram for the selected row in the Variant choices table.
Refresh dialog information from Variant Subsystem contents: Update the Variant choices table according to the Variant system and values of the Variant control in the global workspace.

This read-only field is based on the Variant system name. To add a Subsystem Variant choice, click . To add a Model Variant choice, click .

To enter a Variant name, double-click a Variant control cell in a new row and type in the Variant control expression.

To enter non-numeric Variant control values, use enumerated data. For information about using enumerated data, see Use Enumerated Data in Simulink Models

Programmatic Use

Structure field: Represented by the read-only variant.Name field in the Variant parameter structure
Type: character vector
Value: Variant control that is associated with the Variant choice
Default: 'variant'

This read-only field is based on the condition for the associated Variant control in the global workspace. Create or change a Variant condition in the Simulink.Variant parameter dialog box or in the global workspace.

When you select the Variant control mode to Label, the Label mode active choice option is available. You can select an active Variant choice from Label mode active choice options. You can also right-click the badge on the Variant Subsystem block and select Label Mode Active Choice.

For Label mode active choice option, the Variant control need not be a Boolean condition expression or a Simulink.Variant object. Variant controls that start with a % symbol are ignored.

Note

Label mode active choice option is not available in Expression mode.

Dependencies

To enable this parameter, select Label option from Variant control mode parameter.

Programmatic Use

Parameter: LabelModeActivechoice
Type: character vector
Value: if no Label mode active choice is specified, the value is empty. If Label mode active choice is specified, the value is the name of the Label mode active choice.
Default: ''

To simulate a model (containing a Variant system) without an active Variant choice, select the Allow zero active variant controls option. When you select this option and if there is no active Variant choice, Simulink disables all the blocks connected to the input and output stream of Variant Subsystem block. The disabled blocks are ignored from update diagram or simulation.

If you do not select this option, Simulink generates an error when there is no active Variant choice.

Dependencies

  • The (default) option of Variant is not selected

  • Expression option from Variant control mode is selected.

Programmatic Use

Parameter: AllowZeroVariantControls
Type: character vector
Value: 'off' | 'on'
Default: 'off'

When generating code for an ERT target, this parameter determines whether Variant choices are enclosed within C preprocessor conditional statements (#if).

When you select this option, Simulink analyzes all Variant choices during an update diagram or simulation. This analysis provides early validation of the code generation readiness of all Variant choices.

When you select this option, the Variant badge changes.

Dependencies

  • The check box is available for generating only ERT targets.

  • Expression option from Variant control mode is selected.

Programmatic Use

Parameter: GeneratePreprocessorConditionals
Type: character vector
Value: 'off' | 'on'
Default: 'off'

When you select this option, Simulink propagates the Variant conditions outside of the Variant Subsystem block to determine which components of the model are active during simulation.

When you select this option, the Variant badge indicates the change.

Programmatic Use

Parameter: PropagateVariantConditions
Type: character vector
Value: 'off' | 'on'
Default: 'off'

Block Characteristics

Data Types

Boolean[a] | bus[a] | double[a] | enumerated[a] | fixed point[a] | integer[a] | single[a] | string[a]

Direct Feedthrough

no

Multidimensional Signals

limited[a]

Variable-Size Signals

limited[a]

Zero-Crossing Detection

no

[a] Actual data type or capability support depends on block implementation.

Extended Capabilities

Introduced in R2010b