This example shows how to use the inline variant blocks — Manual Variant Source and Manual Variant Sink. The Manual Variant Source Block provides variation on the source of a signal. The block is a toggle switch that can have two or more input ports and one output port. Each input port is associated with a variant choice. Only one input port can be active during simulation, which in turn determines the active variant region. Similarly, the Manual Variant Sink block provides variation on the destination of a signal. The block can have two or more output ports and one input port. Only one output port can be active during simulation, and the blocks connected to that port determine the active variant.
Open the model
The model has two inline variant blocks, Manual Variant Source and Manual Variant Sink. Both blocks have two variant regions at their input and output ports, respectively. The blocks indicate the currently active variant using a line that connects the input to the output.
To toggle the variant choices in the Manual Variant Source or Manual Variant Sink block, double-click the block. You can also toggle the choices programmatically:
In the MATLAB® Command Window, type:
open_system([bdroot,'/Manual Variant Source']); open_system([bdroot,'/Manual Variant Sink']);
To access the block parameters on a Manual Variant Source or Manual Variant Sink block, right-click the block and select Mask > Mask Parameters. You can change the number of input ports on a Manual Variant Source block or the number of output ports on a Manual Variant Sink block using the Number of Choices parameter.
Simulink® determines the active variant during model compilation, and the generated code contains only the active choices.