addCrossPortConstraint
Class: Simulink.Mask
Namespace: Simulink
Syntax
maskObj.addCrossPortConstraint(crossPortConsObj)
maskObj.addCrossPortConstraint(Name=Value)
Description
maskObj.addCrossPortConstraint(
creates cross-port constraint by using the object of
crossPortConsObj
)Simulink.Mask.CrossPorConstraint
.
maskObj.addCrossPortConstraint(
creates cross-port constraint with additional options specified by one or more
Name=Value
)Name,Value
pair arguments.
Input Arguments
crossPortConsObj
— Cross-port constraint object
Simulink.Mask.CrossPorConstraint
object (default)
Cross-port constraint object, specified as a
Simulink.Mask.CrossPortConstraint
object.
Data Types: char
| string
| cell
Name-Value Arguments
Specify optional pairs of arguments as
Name1=Value1,...,NameN=ValueN
, where Name
is
the argument name and Value
is the corresponding value.
Name-value arguments must appear after other arguments, but the order of the
pairs does not matter.
Before R2021a, use commas to separate each name and value, and enclose
Name
in quotes.
Example: maskObj.addCrossPortConstraint(Name='CheckDimensions',Rule='SameDimension'...
,ParameterConditions={'Name','checkCrossPortDimension','Values',{'on'}},...
Associations={'Input_1','Input_2'},DiagnosticLevel='error',... DiagnosticMessage="The
inputs to the masked block must be of same dimensions")
Name
— Name of constraint
character vector (default)
Name of cross-port constraint, specified as a character vector.
Data Types: char
| string
Rule
— Rule for constraint
Same Dimension
(default) | Same Datatype
Rule for the cross-port constraint, specified as a character vector.
Data Types: char
| string
ParameterConditions
— Parameter conditions for cross-port constraint
Simulink.Mask.ParameterCondition
object (default)
Mask parameter conditions, specified as an object of
Simulink.Mask.ParameterCondition
.
Data Types: char
| string
Associations
— Associate port identifiers to the cross-port constraints
cell array (default)
Associate port identifiers with cross-port constraints, specified as a cell array. Separate identifiers with commas.
Data Types: cell
DiagnosticLevel
— Type of diagnostic message
error
(default) | warning
Type of diagnostic message displayed when validation condition fails, specified as error or warning.
Data Types: char
| string
DiagnosticMessage
— Diagnostic message
error
(default) | warning
Diagnostic message to display when validation fails, specified as character vector.
Data Types: char
| string
Examples
Add Cross Port Constraint
This example shows how to create cross port constraint programmatically using cross port constraint object and name=value pair arguments.
Create Cross Port Constraint Using Name=Value Pair
new_system('crossportconstraint'); add_block('built-in/subsystem','crossportconstraint/subsystem'); save_system; open_system('crossportconstraint'); % Create mask maskObj= Simulink.Mask.create(gcb); % Add a mask parameter to create parameter condition maskObj.addParameter(Name='checkCrossPortDimension',Type='edit'); % Create port identifiers to associate it to the cross port constraint maskObj.addPortIdentifier(Name='Input_1',Type='Input',IdentifierType='index',Identifier='1'); maskObj.addPortIdentifier(Name='Input_2',IdentifierType='name',Identifier='Input_2'); maskObj.addPortIdentifier(Name='Output_1',Type='Output',IdentifierType='index',Identifier='1'); % Create cross port constraint maskObj.addCrossPortConstraint(Name='CheckDimensions',Rule='SameDimension'... ,ParameterConditions={'Name','checkCrossPortDimension','Values',{'on'}},... Associations={'Input_1','Input_2'},DiagnosticLevel='error',... DiagnosticMessage="The inputs to the masked block must be of same dimensions")
ans = CrossPortConstraint with properties: Name: 'CheckDimensions' Rule: 'SameDimension' ParameterConditions: [1x1 Simulink.Mask.ParameterCondition] Associations: {2x1 cell} DiagnosticLevel: 'error' DiagnosticMessage: 'The inputs to the masked block must be of same dimensions'
Create Cross Parameter Constraint Using Object of Simulink.Mask.CrossPortConstraint
% Create an instance of Simulink.Mask.CrossPortConstraint crossPortConst = Simulink.Mask.CrossPortConstraint; % Set the properties of the object using dot notation crossPortConst.Name = 'CheckDatatype'; crossPortConst.Rule = 'SameDataType'; crossPortConst.Associations = {'Input_1','Input_2','Output_1'}; crossPortConst.DiagnosticLevel = 'error'; crossPortConst.DiagnosticMessage = 'The Input_1 and Output_1 should have same DataType'; maskObj.addCrossPortConstraint(crossPortConst)
ans = CrossPortConstraint with properties: Name: 'CheckDatatype' Rule: 'SameDataType' ParameterConditions: [0x0 Simulink.Mask.ParameterCondition] Associations: {3x1 cell} DiagnosticLevel: 'error' DiagnosticMessage: 'The Input_1 and Output_1 should have same DataType'
save_system;
Version History
Introduced in R2023a
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)