Main Content
setRule
Syntax
consObj.setRule(rule)
consObj.setRule(Name=Value)
Description
consObj.setRule(
adds the object
of type rule
)Simulink.Mask.PortConstraintRule
rule to the object.
consObj.setRule(
creates a rule using name-value arguments and adds it to port constraint object.Name=Value
)
Input Arguments
Examples
Set Rules Using ConstraintRule Object
%Get an instance of Simulink.Mask.PortConstraintRule consObj=Simulink.Mask.PortConstraint; rule = Simulink.Mask.PortConstraintRule; pc1.DataType = {'double','int32'}; pc1.complexity = {'real'}; consObj.setRule(rule);
Set Rules as Name-Value Pair Arguments
% Create an instance of Simulink.Mask.PortConstraint to set the rule constraint.setRule('DataType',{'fixedpoint'},'Dimension',{'scalar'}, 'Complexity',{'real'})
ans = PortConstraintRule with properties: DataType: {'fixedpoint'} Dimension: {'scalar'} Complexity: {'real'} FixedPointConstraint: [1×1 Simulink.Mask.FixedPointConstraint]
rule = constraint.getRule
rule = PortConstraintRule with properties: DataType: {'fixedpoint'} Dimension: {'scalar'} Complexity: {'real'} FixedPointConstraint: [1×1 Simulink.Mask.FixedPointConstraint]
%Define the properties of FixedPointConstraint rule.FixedPointConstraint.Scaling = "binary"; rule.FixedPointConstraint.Signedness = "unsigned"; rule.FixedPointConstraint.WordLength = "[8:12]"; rule.FixedPointConstraint
ans = FixedPointConstraint with properties: Scaling: 'binary' Bias: '' Signedness: 'unsigned' WordLength: '[8:12]'
Version History
Introduced in R2022a