主要内容

getConstraint

R2026b

Get constraint from variant configurations object

Since R2026b

    Description

    constraint = getConstraint(varConfigs,ConstraintName=constraintName) returns the constraint named constraintName from the Simulink.VariantConfigurations object varConfigs.

    example

    Examples

    collapse all

    Create a Simulink.VariantConfigurations object and add a constraint with a condition expression and description.

    varConfigs = Simulink.VariantConfigurations;
    varConfigs.addConstraint("PlantLocConstraint", ...
     Condition="~(PlantLoc ==  PlantLocation.External)",Description="Plant location must not be external");

    Get the constraint.

    constraint = getConstraint(varConfigs,ConstraintName="PlantLocConstraint")
    constraint = 
    
      struct with fields:
    
               Name: 'PlantLocConstraint'
          Condition: 'Condition'
        Description: '~(PlantLoc ==  PlantLocation.External)'

    Input Arguments

    collapse all

    Variant configurations object from which to get the constraint, specified as a Simulink.VariantConfigurations object.

    Name of the constraint to get from the variant configurations object, specified as a character vector or string scalar. The constraint must be defined in varConfigs.

    Example: "PlantLocConstraint"

    Output Arguments

    collapse all

    Constraint, returned as a structure with these fields.

    FieldTypeDescription
    Namechar

    Name of the constraint.

    Conditionchar

    Boolean condition expression of the constraint.

    Descriptionchar

    Description of the constraint.

    Version History

    Introduced in R2026b