Simulink.VariantVariable Class
Namespace: Simulink
Description
Use the Simulink.VariantVariable
class to create a variant parameter
object. Variant parameter objects enable you to vary the values of block parameters in a
Simulink® model conditionally. For an overview of variant parameters, see Use Variant Parameters to Reuse Block Parameters with Different Values.
You can specify multiple values for a variant parameter object and also set properties
such as data type and dimensions applicable to all the choice values. Each value of the
variant parameter object is associated with a variant condition expression. After creating the
object, use it to set the value of block parameters in a model, such as the
Gain parameter of a Gain block. During simulation, the
value associated with the variant condition that evaluates to true
becomes
the active value for that parameter. The values associated with the conditions that evaluate
to false
become inactive.
Before you create a new Simulink.VariantVariable
object, create a Simulink.VariantControl
object representing the variant control variable to be used
in the Simulink.VariantVariable
object. Use these variant control variables to
specify the variant condition expression associated with each choice value of a variant
parameter, for example, 'V == 1'
where V
is a
Simulink.VariantControl
object. The Simulink.VariantControl
object allows you to specify an ActivationTime
for the variant parameter and a Value
that is
used to evaluate the variant conditions and determine the active choice of the variant
parameter. For examples on usage of each type of variant control value, see Use Variant Control Variables in Variant Parameters.
Note
You create a variant parameter object in the base workspace or in a data dictionary. You
can add Simulink.VariantVariable
and Simulink.VariantControl
objects to the base workspace or the Design Data section of a data
dictionary either programmatically or from the Add menu in the Model
Explorer.
To edit a variant parameter object, double-click the object from the workspace or data
dictionary to open the Simulink.VariantVariable
dialog box.
Variant Conditions Legend does not display the variant conditions for variant parameters. Use the Variant Parameters tab in the Variant Manager window to view and manage the variant parameters present in the base workspace or data dictionaries associated with the model. See Variant Manager for Simulink.
Creation
creates an empty
variant parameter object.P
= Simulink.VariantVariable
creates a variant parameter object and sets Properties
using one or more P
= Simulink.VariantVariable(Name,Value
)Name,Value
arguments. Use this syntax to specify
multiple values for the object and to associate each value with a variant condition
expression. You can also specify other properties of the object such as data type, storage
class, and dimension.
Properties
Methods
Examples
Limitations
The Value property of the variant control variable (
Simulink.VariantControl
) that determines the active value of a variant parameter must be an integer, an enumeration, aSimulink.Parameter
object with value of type integer or enumeration, or a user-defined type that inherits fromSimulink.Parameter
.Only the values of the variant parameters change based on the variant condition that evaluates to
true
. Other properties, such as storage class, data types, and so forth, remain the same irrespective of the variant condition.Variant parameters can only be defined in a base workspace or a data dictionary.
Variant parameters that are part of a variant parameter bank do not support AUTOSAR code generation.