Variant Inline Components - MATLAB & Simulink (original) (raw)

Implement structural variations in a single layer

With inline 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 single layer. Such models have a fixed common structure and a finite set of variable components that are activated or deactivated depending on the variant control. You can activate the components automatically or manually.

For example, suppose you want to simulate a model to control the speed of a car windshield wiper by using different rain sensors. You can provide the rain sensor models as inputs to a Variant Source block and then switch between the sensors based on the variant control you select. For more information, see Introduction to Variant Controls.

The code that you generate for the inline 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 inline variant blocks, see Variant Structures (Simulink Coder).

Blocks

Variant Source Route among multiple inputs using variants
Variant Sink Route amongst multiple outputs using variants
Variant Start Define start of bounded region (Since R2024a)
Variant End Define end of bounded region (Since R2024a)
Manual Variant Source Switch between multiple variant choices at input
Manual Variant Sink Switch between multiple variant choices at output

Classes

Simulink.VariantControl Create a variant control variable object (Since R2021a)
Simulink.Parameter Store, share, and configure parameter values
Simulink.VariantExpression 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

Automatically Select Variant Source and Destination Signals

Manually Specify Variant Source and Destination Signal

Troubleshooting

Transform Model to Variant System (Simulink Check)

Use the Model Transformer tool to transform a model into a variant system.

Create a Simple Variant Model

Create a Simple Variant Model

Create a simple model with variant blocks.

Approaches to Control Active Variant Choice of a Variant Block Using Mask or Model Workspace

Approaches to Control Active Variant Choice of a Variant Block Using Mask or Model Workspace

Control the active choice of inline variant and Variant Subsystem blocks from a mask or a model workspace.