Represent a subsystem with multiple subsystems
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.
For more information, see Data Types Supported by Simulink in the Simulink documentation.
Displays a table of variant choices, variant control, and conditions. The Variant control that evaluates to true determines the active variant.
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:
You can use buttons to the left of the Variant choices table to modify the elements in the table.
|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.|
Name of the subsystem (a subsystem contained in the Variant Subsystem block)
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 .
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.
To enter a variant name, double-click a Variant control cell in a new row and type in the variant control expression.
|Structure field: Represented by the variant.Name field in the Variant parameter structure|
|Value: Variant control that is associated with the variant choice.|
Displays the Condition for the variant controls that are of type Simulink.Variant object.
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.
Specify whether to designate the active variant from the evaluation of the variant conditions or from the value of the Variant parameter.
Override the variant conditions and set the active variant to the variant choice represented by the Variant field.
Determine the active variant by the value of the variant conditions.
This parameter enables Variant.
|Value: '' if no overriding variant is specified.|
Specify the name of the variant to use if you select Override variant conditions and use the following variant.
Must be a valid MATLAB® identifier.
You can use the Variant drop-down list to see a list of all variants currently in the base workspace.
Enable variants and Override variant conditions and use the following variant enables this parameter.
|Value: Specified by the variant control expression.|
Control whether generated code contains preprocessor conditionals for this Variant Subsystem block.
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.
|Value: 'off' | 'on'|