Main Content

setChoice

Modify existing choices of variant parameter object

Since R2021a

    Description

    example

    P = setChoice(P,Choices{Condition,Value}) replaces the value associated with the variant condition Condition by the new value Value. You can modify multiple values of variant variable P by specifying condition-value pairs in a cell array. If the choice corresponding to the specified condition already exists, the associated value is overridden. Otherwise, a new choice is added.

    Examples

    collapse all

    Create a Simulink.VariantVariable object.

    P = Simulink.VariantVariable('Choices',{'V==1',8,'V==2',9})

    Modify a variant choice associated with the variant condition V==1.

    P = setChoice(P, {'V==1', 3.5});
    

    Create a Simulink.VariantVariable object.

    P = Simulink.VariantVariable('Choices',{'V==1',8,'V==2',9,'V==3',12})

    Modify variant choices associated with variant conditions V==1 and V==3.

    P = setChoice(P, {'V==1', 3.5,'V==3',20});
    

    Input Arguments

    collapse all

    Variant parameter object created using Simulink.VariantVariable, specified as a Simulink.VariantVariable object. This object is updated with the new values that you specify using setChoice.

    Variant condition and its associated value, specified as a cell array. Simulink® replaces the existing value of the specified variant condition with the new value. You can modify multiple values of the object by specifying condition-value pairs in a cell array.

    You can specify the variant condition as boolean MATLAB® expressions that contain one or more operands and operators. See Types of Variant Control Variables (Operands) in Variant Parameters and Types of Operators in Variant Parameters.

    Example: {'V==2',5}

    Data Types: struct

    Version History

    Introduced in R2021a