Simulink.VariantExpression
Specify conditions that control variant selection
Description
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 or A==1 && B == 2. In these
expressions, the variant control variables A and B can
be MATLAB® variables, Simulink.Parameter objects, or Simulink.VariantControl objects. For more information, see Switch Between Choices Using Condition Expressions in Variant Blocks.
Create a Simulink.VariantExpression object 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. Using
Simulink.VariantExpression objects lets you reuse common variant conditions
across models and improves the readability of variant condition expressions.
For example, you can use Simulink.VariantExpression objects as variant
controls in a Variant Source
block.
v_EngType_Big = Simulink.VariantExpression("V == 1"); v_EngType_Small = Simulink.VariantExpression("V == 2");

Note
Defining variant controls using
Simulink.VariantExpressionobjects in a mask workspace or the model workspace is not supported. For more information on storage locations for variant control variables, see Types of Variant Control Variables (Operands) in Variant Blocks.Using
Simulink.VariantExpressionobjects within structures is not supported.
Creation
Description
creates a variant control and sets the variantControl = Simulink.VariantExpression(conditionExpression)Condition property to
conditionExpression.
