addCrossPortParameterConstraint
Class: Simulink.Mask
Namespace: Simulink
Create cross port parameter constraint between ports and parameters of same masked block
Since R2025a
Syntax
maskObj.addCrossPortParameterConstraint(crossPortParamConsObj)
maskObj.addCrossPortParameterConstraint(Name=Value)
Description
maskObj.addCrossPortParameterConstraint(
creates cross port parameter constraint by using the object of
crossPortParamConsObj
)Simulink.Mask.CrossPortParameterConstraint
.
maskObj.addCrossPortParameterConstraint(
adds cross port parameter constraint with options specified by one or more
Name=Value
)name-value
pair arguments and add the constraint to the mask
object.
Input Arguments
Name-Value Arguments
Examples
Create Cross Port Parameter Constraint
Create cross port parameter constraint and associate them among mask parameters and ports of the same block.
Load the model and get the mask object of the block mx + b
.
model = "slexMaskingBasic.slx"; load_system(model); maskObj = Simulink.Mask.get("slexMaskingBasic/mx + b");
Create a mask parameter Speed
and Torque
.
maskObj.addParameter(Name="Speed",Type="edit"); maskObj.addParameter(Name="Torque",Type="edit");
Create port identifiers for the ports.
maskObj.addPortIdentifier(Name="Input_1",Type="Input",IdentifierType="index",Identifier="1"); maskObj.addPortIdentifier(Name="Output_1",Type="Output",IdentifierType="index",Identifier="2");
Add Cross Port Parameter Constraint Using Mask Object
Add cross port parameter constraint.
maskObj.addCrossPortParameterConstraint(... Name="CheckDataType", ... Rule="SameDataType", ... Associations = {"Parameters", {'Torque'}, "PortIdentifiers", {'Input_1','Output_1'}}, ... DiagnosticLevel="error", ... DiagnosticMessage="The input port and parameter must be of the same datatype")
ans = CrossPortParameterConstraint with properties: Name: 'CheckDataType' Rule: 'SameDataType' ParameterConditions: [0×0 Simulink.Mask.ParameterCondition] Associations: [1×1 Simulink.Mask.CrossPortParameterAssociation] DiagnosticLevel: 'error' DiagnosticMessage: 'The input port and parameter must be of the same datatype'
Add Cross Port Parameter Constraint Using Simulink.Mask.CrossPortParameterConstraint
Object
Create cross port constraint from a Simulink.Mask.CrossPortParameterConstraint
object.
crossPortParamConsObj = Simulink.Mask.CrossPortParameterConstraint; crossPortParamConsObj.Name = "CheckDimension"; crossPortParamConsObj.Rule = "SameDimension"; crossPortParamConsObj.DiagnosticLevel = "error"; crossPortParamConsObj.DiagnosticMessage = "The input port and parameter must have same dimension";
Associate cross port parameter constraint to parameters and port identifiers using Simulink.Mask.CrossPortParameterAssociation
object.
% assoc = Simulink.Mask.CrossPortParameterAssociation; % assoc.Parameters = {"Speed"}; % assoc.PortIdentifiers = {"Input_1"}; % crossPortParamConsObj.Associations = assoc;
Alternatives
You can also create cross port parameter constraint from the Mask Editor.
Version History
Introduced in R2025a