Simulink.VariantManager.validateConstraint - Verify if variant constraint is satisfied by model hierarchy - MATLAB (original) (raw)

Main Content

Verify if variant constraint is satisfied by model hierarchy

Since R2025a

Syntax

Description

Simulink.VariantManager.validateConstraint([modelname](#mw%5Faa6e4182-d963-456b-879a-956a097b5534),Constraint=[constraintname](#mw%5Fa679cb51-02c6-417d-99a6-8280ad888eb5)) checks if the constraint named constraintname in the variant configuration data object associated with the model modelname is satisfied by the model and the referenced components in the model hierarchy. The function reports an error if the constraint fails for any of the variant configurations present in the associated variant configuration data object. The function does not return any value if the constraints are satisfied by the model.

example

Simulink.VariantManager.validateConstraint([modelname](#mw%5Faa6e4182-d963-456b-879a-956a097b5534),Condition=[conditionexpr](#mw%5F0d15ec36-edb5-4fa4-9694-0b5035966778)) checks if the constraint condition conditionexpr is satisfied by the model modelname and the referenced components in the model hierarchy. Use this syntax to specify a condition expression that can include a combination of control variables and configuration names instead of a constraint name.

example

Examples

collapse all

Check if the variant constraint LinNotExtern is satisfied by the model slexVariantManagement.

modelname="slexVariantManagement"; open_system(modelname); Simulink.VariantManager.validateConstraint ... (modelname,Constraint="LinNotExtern");

Check if a variant constraint given by an expression is satisfied by the model hierarchy.

Simulink.VariantManager.validateConstraint ... (modelname,Condition="~(Ctrl==ControllerType.Linear && PlantLoc==PlantLocation.External)");

Check if a variant constraint defined by variant configurations of a referenced component is satisfied by the model hierarchy. Here, subvcd is the variant configuration data object of a referenced model in the hierarchy.

refmodelname = "slexVariantManagementExternalPlantMdlRef"; open_system(refmodelname); subvcd = Simulink.VariantManager.getConfigurationData(refmodelname); Simulink.VariantManager.validateConstraint(modelname,Condition="(isConfigActive(subvcd,""LowFid"") || isConfigActive(subvcd,""HighFid""))");

Input Arguments

collapse all

Name of the model with which the constraint is associated, specified as a character vector or string scalar.

Example: "slexVariantManagement"

Data Types: char | string

Name of constraint to validate the model with, specified as a character vector or string scalar.

Example: "LinInterExpNoNoise"

Data Types: char | string

Constraint condition expression that can contain a combination of control variables and names of variant configurations of referenced components in the model hierarchy, specified as a character vector or string scalar. The configuration names must be specified using the isConfigActive function call.

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

Example: "(isConfigActive(subvcd,""LowFid"") || isConfigActive(subvcd,""HighFid""))"

Data Types: char | string

Version History

Introduced in R2025a