Documentation Center

  • Trials
  • Product Updates

Variant Subsystem

Represent a subsystem with multiple subsystems

Library

Ports & Subsystems

Description

Variant subsystems provide multiple implementations for a subsystem where only one implementation is active during simulation. You can programmatically swap out the active implementation with another implementation without modifying the model.

The Variant Subsystem block includes multiple child subsystems, where only one subsystem is active during simulation. The Variant Subsystem block can include Inport, Outport, and Connection Port blocks. There are no drawn connections inside the Variant Subsystem block. Each child subsystem is associated with a variant control, which is created in the base workspace. The variant control that evaluates to true, determines the active variant.

Data Type Support

For information on the data types accepted by a subsystem input ports, see Inport block. For information on data types output by a subsystem output ports, see Outport block.

For more information, see Data Types Supported by Simulink in the Simulink documentation.

Mapping Inports and Outports

Each subsystem block within a Variant Subsystem represents one variant configuration. These subsystem blocks can have different numbers of inports and outports than their parent variant subsystem, provided the following conditions are satisfied.

  • The inport names on a variant are a subset of the inport names used by the parent variant subsystem.

  • The outport names are a variant are a subset of the outport names used by the parent variant subsystem.

During simulation, Simulink® disables the inactive ports in a variant subsystem block.

Parameters and Dialog Box

Variant choices (list of child subsystems)

Displays a table of variant choices, variant control, and conditions. The Variant control that evaluates to true determines the active variant.

Settings

Default: The table has a row for each subsystem in the Variant Subsystem block. If the Variant Subsystem block does not contain any subsystems, then the table is empty. See each column parameter for its default value:

Tip

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: Places a new subsystem choice in the table and creates a new subsystem block in the Variant Subsystem block diagram.
Create/Edit selected variant object: Creates a Simulink.Variant object in the base workspace and opens the Simulink.Variant object parameter dialog box to specify the variant Condition.
Open selected subsystem variant choice: Opens the subsystem block diagram for the selected row in the Variant choices table.
Refresh dialog information from variant subsystem contents: Updates the Variant choices table according to the Subsystem block configuration and values of the variant control in the base workspace.

See Also

Name (read-only)

Name of the subsystem (a subsystem contained in the Variant Subsystem block)

Settings

A read only field, based on the subsystems contained in the Variant Subsystem block. To add a new subsystem to the Variant Subsystem block, click the Create and add a new subsystem choice button .

Variant Control

Displays the variant controls available in the base workspace. The variant control can be a boolean condition expression, or a Simulink.Variant object representing a boolean condition expression. If you want to generate code for your model, you must define the control variables as Simulink.Parameter objects.

Settings

Default: Variant

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

Command-Line Information

Structure field: Represented by the variant.Name field in the Variant parameter structure
Type: string
Value: Variant control that is associated with the variant choice.
Default: ''

Condition (read-only)

Displays the Condition for the variant controls that are of type Simulink.Variant object.

Settings

A read-only field, based on the condition for the associated variant control in the base workspace. Create or change a variant condition in the Simulink.Variant parameter dialog box or in the base workspace.

See Also

Override variant conditions and use following variant

Specify whether to designate the active variant from the evaluation of the variant conditions or from the value of the Variant parameter.

Settings

Default: Off

On

Override the variant conditions and set the active variant to the variant choice represented by the Variant field.

Off

Determine the active variant by the value of the variant conditions.

Dependencies

This parameter enables Variant.

Command-Line Information

Parameter: OverrideUsingVariant
Type: string
Value: '' if no overriding variant is specified.
Default: ''

See Also

Variant

Specify the name of the variant to use if you select Override variant conditions and use the following variant.

Settings

Default: ''

Must be a valid MATLAB® identifier.

Tips

You can use the Variant drop-down list to see a list of all variants currently in the base workspace.

Dependencies

Enable variants and Override variant conditions and use the following variant enables this parameter.

Command-Line Information

Parameter: OverrideUsingVariant
Type: string
Value: Specified by the variant control expression.

See Also

Generate preprocessor conditionals

Control whether generated code contains preprocessor conditionals for this Variant Subsystem block.

Settings

Default: Disabled

Dependencies

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

  • Override variant conditions and use following variant is cleared ('off')

  • Model Configuration Parameters > Optimization > Signals and Parameters > Inline parameters is selected ('on')

  • Model Configuration Parameters > Code Generation > Interface > Generate preprocessor conditionals is set to Use local settings.

Command-Line Information

Parameter: GeneratePreprocessorConditionals
Type: string
Value: 'off' | 'on'
Default: 'off'

See Also

Was this topic helpful?