Variant Sink
R2026bRoute amongst multiple outputs using variants
Libraries:
Simulink /
Signal Routing
Description
The Variant Sink block enables you to include multiple implementations of a component on the destination (sink) of a signal in a single layer.
For example, suppose you want to simulate this model to control the speed of the car
windshield wiper by using different rain sensors. The Variant Source block switches between different rain sensors. The control
logic uses this information to output the result to the Variant Sink
block. The Variant Sink then switches between the wiper motor model
during simulation and the D/A (Digital-to-Analog) block output during
code generation. The variant blocks switch between choices based on the Types of Variant Control Modes in Variant Blocks you select. For
more information, see Introduction to Variant Controls.
Note
At most, one variant choice connected to output port of the Variant Sink block is active during simulation.

The Variant Sink block has only one input port and one or more output ports. You can connect the varying choices to the output port of the block so that, at most, one choice is active during model execution.
The Variant Sink block is associated with a Variant control mode and a Variant activation time. The variant control mode determines how to specify the variant control. 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. During simulation, Simulink® connects the active choice directly to the input port of the Variant Sink block and ignores the inactive choices.
Using a Variant Sink block allows you to:
Propagate variant conditions throughout the model.
Visualize all possible implementations of variant choices in a single layer of your model, which improves model readability.
Simulink eliminates inactive blocks throughout the model, which improves runtime performance. If all the variant choices are inactive, Simulink removes the variant region completely from your model.
Variant sources and sinks provide variant component interfaces that you can use to quickly model variant choices.
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 Allow zero active variant controls parameters set on the block. For more information, see Variant Badges.
Examples
Limitations
The Variant Sink block works with time-based, function-call, and action signals. You cannot use SimEvents®, Simscape™ Multibody™, or other non-time-based signals with these blocks.
Ports
Input
Output
Parameters
Block Characteristics
Data Types |
|
Direct Feedthrough |
|
Multidimensional Signals |
|
Variable-Size Signals |
|
Zero-Crossing Detection |
|
Programmatic Use: Add Block
To add the block programmatically, use the add_block function with one of these library block paths as the source.
"simulink/Signal Routing/Variant Sink"
Example: add_block("simulink/Signal Routing/Variant Sink","myModel/myBlock",MakeNameUnique="on")
For information about programmatic access to individual block parameters, see the Programmatic Use section of parameter descriptions on this page.
Extended Capabilities
Version History
Introduced in R2016aSee Also
Variant Source | Manual Variant Source | Manual Variant Sink | Variant Subsystem
Topics
- Generate Code for Variant Source and Variant Sink Blocks (Simulink Coder)
