Specify conditions that control variant selection
In a model that contains variant blocks, you must associate each variant choice with a
variant control. During simulation, Simulink® evaluates the variant controls of all variant choices and activates the choice
that corresponds to the variant control that evaluates to true
You can specify the variant control in the form of a Boolean condition expression, such as
A == 1
and A==1 && B == 2
. In these
expressions, the variant control variables A
be MATLAB® variables, Simulink.Parameter
objects. For more information, see Switch Between Choices Using Condition Expressions in Variant Blocks.
Create an object of the Simulink.VariantExpression
class to represent a
Boolean variant condition expression. You can define the object in the base workspace or in a
data dictionary and use the object as the variant control for a choice in a variant block.
objects lets you reuse common variant
conditions across models and improves the readability of variant condition expressions.
In this example, Simulink.VariantExpression
objects are used as variant
controls in a Variant Source
v_EngType_Big = Simulink.VariantExpression('V == 1'); v_EngType_Small = Simulink.VariantExpression('V == 2');
Defining variant controls using
objects in the mask or model workspace is not supported. For more information on storage locations for variant control variables, see Storage Locations for Variant Control Variables (Operands) in Variant Blocks.Using
objects within structures is not supported.