Invalid constraint attribute name for addCrossPa​rameterCon​straint

I am building a Simulink mask programatically and came across an issue while trying to add a cross-parameter constraint with maskObj.addCrossParameterConstraint. It requires a constraint name and a rule (error message is optional). However, 'Rule' comes up as an invalid constraint attribute name. Anyone else come across this or know what the attribute name should be?
**My script:
blockMask.addCrossParameterConstraint('Name','UniquePortNames',...
'Rule','strcmpi(PortName_1,PortName_2)==0',...
'ErrorMessage','Some ports are not accounted for.');
**Result in command line:
Invalid constraint attribute name, 'Rule'.

回答 (1 件)

MJ Canavate Sanchez
MJ Canavate Sanchez 2021 年 3 月 19 日

0 投票

Hi Rachel, try setting the property name to 'MATLABexpression' rather than 'Rule':
CrossConstraint = maskHandle.addCrossParameterConstraint('Name','constraint1',...
'MATLABexpression','mod(parameter1,parameter2) == 0','ErrorMessage','Invalid parameter')

カテゴリ

ヘルプ センター および File ExchangeAuthor Block Masks についてさらに検索

質問済み:

2019 年 2 月 6 日

回答済み:

2021 年 3 月 19 日

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by