Specify a model reference variant and its execution environment
Simulink.Variant object specifies a variant
object, which is defined using a Boolean expression called a variant
condition. A Variant Subsystem block (or optionally, a Model Variant
block) use variant objects to associate an execution environment with
each of its variants.
The variant condition references MATLAB® variables and/or Simulink® parameter
objects in the base workspace called variant control variables. The
variant condition must evaluate to
the model is compiled.
For a given Model Variants block or Variant Subsystem block,
you must define the variant objects so that only one evaluates to
The variant object, whose variant condition evaluates to
is the active variant for that variant block.
a variant object in the base workspace. The object name is
and the associated variant condition is
The object can have any unique legal MATLAB name.
VariantCondition must be a Boolean
expression that references at least one base workspace variable or
parameter. A variant condition can include scalar variables, enumerated
values, the operators
as well as parentheses for grouping. If you specify the condition
literally, surround it with single quotes.
You can also create a variant object using the Model explorer.
Select the Base Workspace, choose Add >
and specify the desired name and variant condition in the Contents
and Dialog panes. If you specify the condition literally, do not surround
it with single quotes (unlike the MATLAB API, which requires
The Boolean expression associated with the variant object.
Create a variant object with a variant condition:
GU=Simulink.Variant('Fuel==1 && Emis==1')