Variant Subsystem, Variant Model, Variant Assembly Subsystem
Template subsystem containing Subsystem, Model, or Subsystem Reference blocks as variant choices
- Library:
Simulink / Ports & Subsystems
HDL Coder / Ports & Subsystems
Description
The Variant Subsystem block enables you to include multiple implementations of a component in a separate hierarchy.
For example, suppose you want to simulate a model that represents a vehicle with three possible engine configurations: 4-cylinder gas, 6-cylinder gas, and 8-cylinder gas. You could implement each engine model as a separate subsystem inside the Variant Subsystem and then switch between the subsystems based on the Types of Variant Control Modes in Variant Blocks you select. For more information, see Introduction to Variant Controls.
Note
Only one implementation of a Variant Subsystem is active during simulation.
The Variant Subsystem block is a template preconfigured to contain two or more blocks to use as Variant choices. These choices represent multiple implementations of a system. Only one child block is active during model execution. The active child block is referred to as the active variant.
Each variant choice inside the Variant Subsystem block is associated with a Variant control mode and a Variant activation time. The variant control mode determines how to select the active variant. The variant activation time determines a time to activate the choices and to decide whether to include only the active choice or both active and inactive choices in the generated code.
A Variant Subsystem block can contain a mixture of Subsystem blocks, Model blocks, or Subsystem Reference blocks as variant choices. A Variant Subsystem block with Model blocks as choices is called a Variant Model block. For more information, see Represent Variant Choices in a Variant Subsystem. A Variant Subsystem block that references model or subsystem files using Variant choices specifier is called a Variant Assembly Subsystem block.
Apart from the variant choices, you can include Inport, control port (Enable, Trigger, Reset, and Function-Call), Outport, or Connection Port (Simscape) blocks inside a Variant Subsystem block. There are no drawn connections between the blocks that are inside the Variant Subsystem blocks. Simulink® automatically wires the active variant to the Inport and Outport blocks of the Variant Subsystem during model compilation. The blocks representing variant choices can have input and output ports that differ in number from the input and output ports in the parent Variant Subsystem block. For more information, Map Inports and Outports of Variant Choices in Variant Subsystem.
Using Variant Subsystem block allows you to:
Mix Subsystem, Model, and Subsystem Reference blocks as variant choices.
Model components that do not have similar interface. You can have different numbers of inports and outports for multiple variant choices inside a Variant Subsystem. However, the conditions listed in Map Inports and Outports of Variant Choices in Variant Subsystem must be met.
Establish a hierarchical block diagram, where the Variant Subsystem block is on one layer and the variant choices are on another layer.
Keeps functionally related blocks together.
Reduce the complexity of your model.
During model compilation, Simulink eliminates inactive blocks throughout the model, depending on the variant activation time you select.
The color and icon of the variant badge on the block icon changes depending on the values of the Variant activation time, Variant control mode, and Propagate conditions outside of variant subsystem parameters set on the block. For more information, see Variant Badges.
Variant Assembly Subsystem
A Variant Assembly Subsystem block enables you to add or remove its variant choices from external sources without modifying the model. A Variant Assembly Subsystem block can contain Model blocks, Subsystem Reference blocks, or both as its variant choices. Use the Variant choices specifier parameter to specify the variant choices without navigating inside the block. Unlike Variant Subsystem, you cannot manage the variant choices from inside the Variant Assembly Subsystem block.
To add Model or Subsystem Reference blocks as variant choices:
Maintain the model and subsystem files to be referenced on the MATLAB® path.
Specify a valid MATLAB expression in the Variant choices specifier parameter that evaluates to a one-dimensional cell array of character vectors. Every cell in the array must either be a model file name or a subsystem file name. The cell can also contain a file name pattern that matches the model, or the subsystem file names as described in Specify Variant Choices of Variant Assembly Subsystem Block in Variant Choices Specifier Parameter. The Variant Assembly Subsystem block then adds the Model and Subsystem Reference blocks from the listed files as variant choices of the block.
For more information, see Add or Remove Variant Choices of Variant Assembly Subsystem Blocks Using External Files.
Note
To convert a Variant Subsystem block to a Variant Assembly Subsystem block, follow the steps in Convert Variant Subsystem to Variant Assembly Subsystem. After the conversion, all the choices are maintained in separate model or subsystem files with the same name as the choices.
Ports
During simulation, Simulink disables the inactive ports in a Variant Subsystem block.
Input
Output
Parameters
Model Examples
Block Characteristics
Extended Capabilities
Version History
Introduced in R2010b