Main Content


Class: Simulink.Mask
Package: Simulink

Add parameter constraint to a mask


paramConstraint = maskObj.addParameterConstraint(Name,Value)


paramConstraint = maskObj.addParameterConstraint(Name,Value) adds a constraint to the specified mask. Constraints can only be associated to the Edit type mask parameters.

Input Arguments

expand all

Block mask handle, specified as a mask object. You can use the Simulink.Mask.get command to get the block mask handle. For more information, see Simulink.Mask.get

Data Types: char | cell

Name-Value Arguments

Specify optional comma-separated pairs of Name,Value arguments. Name is the argument name and Value is the corresponding value. You can specify several name and value pair arguments in any order as Name1,Value1,...,NameN,ValueN.

Required field. Must be a valid MATLAB name. Specifies a name for the mask parameter constraint.

Optional field. Specifies the Edit mask parameter name to which you want to associate the constraint.

Required field. Rules are defined within curly braces. A constraint can have single or multiple rules.

Name-Value Pairs for Rules



DataTypedouble, single, numeric, integer, int8, uint8, int16, uint16, int32, uint32, boolean, enum, fixdt
Dimensionscalar, row vector, column vector, 2-D matrix, n-D matrix
Complexityreal, complex
Signpositive, negative, zero
Finitenessfinite, inf, -inf, NaN
Minimumcharacter vector
Maximumcharacter vector

Valid MATLAB expression returning logical true or false.

CustomErrorMessagecharacter vector or a message catalog ID. If you use the message catalog ID to specify an error, the error message must not have any holes in it. This error message is specifically for custom constraint validation failure.

Output Arguments

expand all

Handle to the mask parameter constraint, returned as a character vector. You can associate a constraint to the mask parameter either during or after creating the constraint.


expand all

Get block mask handle.

maskObj = Simulink.Mask.get(gcb); 

Create mask constraint.

paramConstraint = maskobj.addParameterConstraint(...
paramConstraint = 

  Constraints with properties:

               Name: 'const2'
    ConstraintRules: [1×1 Simulink.Mask.ParameterConstraintRules]

Version History

Introduced in R2018a