Skip to Main Content Skip to Search
Product Documentation

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 and with another implementation without modifying the model.

The Variant Subsystem block includes multiple child subsystems, where only one subsystem runs during simulation. The Variant Subsystem block also 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 object, which is created in the base workspace. The variant object is defined with a condition to determine if it is the active subsystem.

Data Type Support

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

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

Parameters and Dialog Box

Variant choices (list of child subsystems)

Displays a table of subsystems, variant objects, and conditions, which are Boolean expressions that determine 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 of 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 object 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 diagram. To add a new subsystem to the Variant Subsystem block diagram, click the Create and add a new subsystem choice button .

Variant object

Display the Simulink.Variant objects in the base workspace or enter a variant object name in a new row.

Settings

Default: Variant

To enter a variant object name, double-click a Variant object cell in a new row and type in the variant object name. Define that variant object in the base workspace.

Command-Line Information

Structure field: Represented by the variant.Name field in the Variant parameter structure
Type: string
Value: Name of the Simulink.Variant object that represents the variant to which this element applies.
Default: ''

See Also

Condition (read-only)

Displays the Condition for the Simulink.Variant object.

Settings

A read-only field, based on the condition for the associated variant object 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 value of the Variant parameter

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 object is specified, or the name of the overriding variant object
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 variant objects currently in the base workspace.

Dependencies

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

Command-Line Information

Parameter: OverrideUsingVariant
Type: string
Value: Name of the Simulink.Variant object

See Also

Generate preprocessor conditionals

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

Settings

Default: Disabled

Dependencies

Command-Line Information

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

See Also

  


Related Products & Applications

Learn more about Simulink through this collection of videos, articles, technical literature and the Getting Started with Simulink Guide.

 © 1984-2012- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS