Documentation

Variant Sink

Route amongst multiple outputs using variants

Library

Signal Routing

Description

The Variant Sink block has one input port and one or more output ports. You can define variant choices as blocks that are connected to the output port so that, at most, one choice is active.

Each output port is associated with a variant control. The variant control that evaluates to true, determines which output port is active.

During simulation, Simulink® connects the active choice directly to the input port of the Variant Sink block and ignores the inactive choices.

Parameters

Ports and associated conditions

A table of port choices, variant controls, and conditions. The Variant control that evaluates to true determines which input port must be active.

Settings

Default: The table has a row for each variant choice exiting in the Variant Sink block. See each column parameter for its default value:

Port

Number of the input port that is connected to one variant choice upstream of the Variant Sink block

Settings

A read-only field, based on the input port that is connected to one variant choice upstream of the Variant Sink block.

Click to add a port or to delete an existing one.

Variant Control

Displays the variant controls available in the base workspace. The variant control can be a Boolean condition expression or a Simulink.Variant object representing a Boolean condition expression. If you want to generate code for your model, you must define the control variables as Simulink.Parameter objects.

Settings

Default: Variant

To enter a variant name, double-click a Variant control cell in a new row and type in the variant control expression. Click Apply after you edit a variant control name. If you add or delete a variant control without applying the changes, the previous edits on the variant control name are lost.

Command-Line Information

Parameter: VariantControls
Type: cell array of character vectors
Value: Variant control that is associated with the variant choice.
Default: ''

Condition (read-only)

Displays the Condition for the variant controls that are Simulink.Variant objects.

Settings

A read-only field, based on the condition for the associated variant control in the base workspace. Create or change a variant condition in the Simulink.Variant parameter dialog box or in the base workspace.

Override variant conditions and use the following variant

Ignores the variant control value while determining the active variant and uses the overridden variant control as the active variant. The overriding variant control must be defined in the variant block dialog box.

If you do not select this option, Simulink determines the active variant choice based on the variant control that evaluates to true in the global workspace.

When you select this option, the variant badge indicates the change.

Settings

Default: Off

On

Use the specified variant instead of selecting the active variant from the variant control.

Off

Determine the active variant choice based on the variant control that evaluates to true.

Dependencies

This parameter enables Variant.

Command-Line Information

Parameter: OverrideUsingVariant
Type: character vector
Value: '' if no overriding variant is specified.
Default: ''

Variant

Select the variant control that Simulink uses if you select Override variant conditions and use the following variant.

Settings

Default: ''

The Variant drop-down list displays all variant controls that are currently defined in the base workspace or a data dictionary. Use valid MATLAB® identifiers to specify variant controls.

Dependencies

Override variant conditions and use the following variant enables this parameter.

Command-Line Information

Parameter: OverrideUsingVariant
Type: character vector
Value: Specified by the variant control expression.

Allow zero active variant controls

To simulate a model (containing a variant block) without an active variant choice, select the Allow zero active variant controls option. When this option is selected and there is no active variant choice, Simulink disables all the blocks connected to the input and output stream of Variant Sink block. The removed blocks are ignored from update diagram or simulation.

If you do not select this option, Simulink generates an error when there is no active variant choice.

When you select this option, the variant badge indicates the change.

Settings

Default: Disabled

Command-Line Information

Parameter: AllowZeroVariantControls
Type: character vector
Value: 'off' | 'on'
Default: 'off'

Show variant condition on block

When you select this option, Simulink annotates each variant control (condition expression) on the Variant Sink block ports.

Settings

Default: Disabled

Command-Line Information

Parameter: ShowConditionOnBlock
Type: character vector
Value: 'off' | 'on'
Default: 'off'

Analyze all choices during update diagram and generate preprocessor conditionals

When you select this option, Simulink analyzes all variant choices during an update diagram or simulation. This analysis helps Simulink to maintain consistency of all variant branches during simulation and code generation. Simulink routes the output of the active and inactive regions to an internal VariantMerge block.

When this option is selected, the preprocessor conditionals (#if) are generated in the code with ERT-based targets.

When you select this option, the variant badge indicates the change.

Settings

Default: Disabled

Dependencies

  • The check box is available for generating ERT targets only.

  • Override variant conditions and use following variant is cleared ('off')

Command-Line Information

Parameter: GeneratePreprocessorConditionals
Type: character vector
Value: 'off' | 'on'
Default: 'off'

Characteristics

Data Types

Double | Single | Boolean | Base Integer | Fixed-Point | Enumerated | Bus

Sample Time

Inherited from driving block

Direct Feedthrough

Yes

Multidimensional Signals

Yes

Variable-Size Signals

Yes

Zero-Crossing Detection

No

Code Generation

Yes

Introduced in R2016a

Was this topic helpful?