Variant Hierarchical Components
With hierarchical variant blocks, you can represent all design alternatives of a system in a single model. Each design choice is incorporated into the model as a variant choice in a separate hierarchy. Such models have a fixed common structure and a finite set of variable components that are activated or deactivated depending on the variant controls.
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 can implement each engine model as a separate subsystem inside the Variant Subsystem, Variant Model, Variant Assembly Subsystem block and then switch between the subsystems based on the variant controls you select. For more information, see Introduction to Variant Controls.
The code that you generate for the hierarchical variant blocks can contain all the variant choices of a system. You can switch between the choices prior to code compile or at model startup as described in Activate Variant During Different Stages of Simulation and Code Generation Workflow. For information on generating code with hierarchical variant blocks, see Represent Subsystem and Variant Models in Generated Code (Embedded Coder).
Blocks
Variant Subsystem, Variant Model, Variant Assembly Subsystem | Template subsystem containing Subsystem, Model, or Subsystem Reference blocks as variant choices |
Classes
Simulink.VariantControl | Create a variant control variable object (Since R2021a) |
Simulink.Parameter | Store, share, and configure parameter values |
Simulink.Variant | Specify conditions that control variant selection |
Simulink.VariantUtils | Utility methods to work with variant elements (Since R2023b) |
Functions
enumeration | Class enumeration members and names |
Objects
struct | Structure array |
Topics
- Implement Variations in Separate Hierarchy Using Variant Subsystems
Learn basic functionality of variant subsystems.
- Variant Control Modes in Variant Blocks
Learn how to control variant blocks.
- Propagate Variant Conditions to Define Variant Regions with Variant Blocks
Determine active model components by propagating variant conditions using variant blocks.
- Propagate Variant Conditions to Define Variant Regions Outside Variant Subsystems
Propagate variant conditions outside a Variant Subsystem block to adapt its interface according to the state of underlying blocks.
- Model Reference Variants
This example shows how to use model reference variants.
- Control Active Choice of Locked Custom Library Variant Subsystem Using Mask Parameter
Control active choice of Variant Subsystem that belongs to a locked custom library.
- Add or Remove Variant Choices of Variant Assembly Subsystem Blocks Using External Files
Understand how to add or remove variant choices of the Variant Assembly Subsystem block using external files without modifying model.
- Control Variant Choices in Masked Variant Assembly Subsystem Block Using Mask Parameter Object
Specify variant choices and set an active choice in a masked Variant Assembly Subsystem block.
Troubleshooting
Convert Configurable Subsystem to Variant Subsystem
Learn how to convert configurable subsystems to variant subsystems and their behavior on loading.
Convert Variant Subsystem to Variant Assembly Subsystem
Steps to convert Variant Subsystem block to Variant Assembly Subsystem block.
Transform Model to Variant System (Simulink Check)
Use the Model Transformer tool to transform a model into a variant system.