Variant Inline Components
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 Represent Subsystem and Variant Models in Generated Code (Embedded Coder).
Blocs
Variant Source | Route among multiple inputs using variants |
Variant Sink | Route amongst multiple outputs using variants |
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 |
Simulink.Parameter | Store, share, and configure parameter values |
Simulink.Variant | Specify conditions that control variant selection |
Fonctions
enumeration | Class enumeration members and names |
Objets
struct | Structure array |
Rubriques
Automatically Select Variant Source and Destination Signals
- Define and Configure Variant Sources and Sinks
Represent variant choices using Inline Variants. - Visualize Variant Implementations in a Single Layer
View the variant choices in a model containing Inline Variants. - Variant Control Modes in Variant Blocks
Learn how to control variant blocks. - Variant Condition Propagation with Variant Sources and Sinks
Propagate variant conditions from the Variant Source and Variant Sink blocks. - Propagate Variant Conditions from Variant Source Blocks to Subsystem Blocks
Understand variant condition propagation to virtual and non-virtual subsystems. - Propagate Variant Conditions from Variant Source Blocks to Conditionally Executed Subsystems
Learn about variant condition propagation from Variant Source blocks to conditional subsystems. - Variant Elements Within Buses
Understand how to create variant bus, generate code, and variant condition propagation with bus. - Use Variant Source Block to Receive or Output Function-Call Signals for Simulation and Code Generation
This example shows how a Variant Source block receives function-call signals at its input ports and conditionally merges the signals at its output port.
Manually Specify Variant Source and Destination Signal
- Provide Variation at Source and Destination of a Signal Using Manual Variant Source and Manual Variant Sink Blocks
This example shows how to use the inline variant blocks — Manual Variant Source and Manual Variant Sink.
Résolution des problèmes
Transform Model to Variant System (Simulink Check)
Use the Model Transformer tool to transform a model into a variant system.