Represent a subsystem with multiple subsystems
Ports & 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
the active variant.
For more information, see Data Types Supported by Simulink in the Simulink documentation.
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 on 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.
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 and add a new model choice: Places a new model choice in the table and creates a model block in the Variant Subsystem block diagram.|
|Create/Edit selected variant object: Creates
|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 or model variant choice (contained in the Variant Subsystem block)
A read-only field, based on the subsystem or model variant choice contained in the Variant Subsystem block.
Click to add a subsystem variant choice or to add a model variant choice to the Variant Subsystem block.
Displays the variant controls available in the base workspace.
The variant control can be a boolean condition expression, or a
representing a boolean condition expression. If you want to generate
code for your model, you must define the control variables as
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 |
|Value: Variant control that is associated with the variant choice.|
Displays the Condition for the variant
controls that are of type
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.
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 (
Model Configuration Parameters > Optimization > Signals and
Parameters > Inline parameters is selected (
Model Configuration Parameters > Code Generation > Interface > Generate preprocessor conditionals is set to Use local settings.