Main Content

addParameterConstraint

Class:Simulink.Mask
Package:万博1manbetx

Add parameter constraint to a mask

Syntax

paramConstraint = maskObj.addParameterConstraint(Name,Value)

Description

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

Input Arguments

expand all

Block mask handle, specified as a mask object. You can use theSimulink.Mask.getcommand to get the block mask handle. For more information, seeSimulink.Mask.get

Data Types:char|cell

Name-Value Arguments

Specify optional comma-separated pairs ofName,Valuearguments.Nameis the argument name andValueis the corresponding value. You can specify several name and value pair arguments in any order asName1,Value1,...,NameN,ValueN.

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

Optional field. Specifies the编辑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

Name

Value

DataType double,single,numeric,integer,int8,uint8,int16,uint16,int32,uint32,布尔,enum,fixdt
Dimension scalar,rowvectar,columnvectar,2dmatrix,ndmatrix
Complexity real,complex
符号 positive,negative,zero
Finiteness finite,inf,-inf,NaN
Minimum character vector
Maximum character vector
CustomConstraint

Valid MATLAB expression returning logical true or false.

CustomErrorMessage character 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.

Examples

Create Mask Constraint with Single Rule

% Get block mask handle.maskObj = Simulink.Mask.get(gcb);% Create mask constraint with single rule.paramConstraint = maskObj.addParameterConstraint('Name','const2',...'Parameters',{'参数2'},'Rules', {'DataType',“uint8”})
ans = Constraints with properties: Name: 'const2' ConstraintRules: [1×1 Simulink.Mask.ParameterConstraintRules]

Create Mask Constraint with Multiple Rules

% Get block mask handle.maskObj = Simulink.Mask.get(gcb);% Create mask constraint with multiple rules.paramConstraint = maskObj.addParameterConstraint('Name','const3',...'Parameters',{'Parameter3'},'Rules', {{'DataType',“uint8”},{'DataType', {'fixdt(1,8,4)'}}})
ans = Constraints with properties: Name: 'const3' ConstraintRules: [1×2 Simulink.Mask.ParameterConstraintRules]

版本历史

Introduced in R2018a