Main Content

addConstraint

Class: Simulink.VariantConfigurationData
Namespace: Simulink

Add constraint to variant configuration data object

Description

Note

This method requires Variant Manager for Simulink®.

vcdataObj.addConstraint(nameOfConstraint) adds a constraint with the given name to vcdataObj, which is an object of the Simulink.VariantConfigurationData class.

You can use constraints to check if all the variant configurations present in vcdataObj satisfy certain conditions. The constraint must be specified as a valid Boolean condition expression. Simulink evaluates these constraints during variant configuration activation, model compilation, simulation, and code generation workflows.

example

vcdataObj.addConstraint(nameOfConstraint,condition) adds a new constraint with the given name and condition expression to vcdataObj.

vcdataObj.addConstraint(nameOfConstraint,condition,description) adds a new constraint with the given name, condition expression, and description to vcdataObj.

Input Arguments

expand all

Name of the constraint, specified as a character vector or string.

Example: "LinInternal"

Data Types: char | string

Boolean condition expression that is defined in terms of variant control variables, specified as a character vector or string. The expression must evaluate to true to satisfy the constraint.

Example: "~((Ctrl==ControllerType.Linear) && (PlantLoc==PlantLocation.External))"

Data Types: char | string

Description of the constraint, specified as a character vector or string.

Example: "Linear controller must not have an external plant"

Data Types: char | string

Examples

expand all

Add a new constraint to a variant configuration data object.

Create an empty Simulink.VariantConfigurationData object.

vcd = Simulink.VariantConfigurationData;

Add a constraint named LinInternal to the variant configuration data object vcdataObj.

vcd.addConstraint(Name = "LinInternal", ...
Condition = "~((Ctrl == ControllerType.Linear) && (PlantLoc == PlantLocation.External))", ...
Description = "Linear controller must not have an external plant");

Version History

Introduced in R2013b