主要内容

Advisor.authoring.createBlockConstraintCheck

使用模块约束创建模型顾问检查

说明

check_obj = Advisor.authoring.createBlockConstraintCheck(check_ID,'Constraints',@handle) 创建一个 ModelAdvisor.check 对象 check_obj,为其分配标识符 check_ID,并在约束创建函数 @handle 中指定模块约束。

示例

check_obj = Advisor.authoring.createBlockConstraintCheck(check_ID) 创建一个 ModelAdvisor.check 对象 check_obj,并为其分配标识符 check_ID。使用 Advisor.authoring.generateBlockConstraintsDataFile 函数创建模块约束数据文件。使用 setInputParameters 函数,将模块约束数据文件指定为 ModelAdvisor.check 对象的输入参数。有关详细信息,请参阅 Advisor.authoring.generateBlockConstraintsDataFile

注意

Advisor.authoring.createBlockConstraintCheck 创建的 ModelAdvisor.Check 对象不支持设置排除。

示例

全部折叠

此示例说明如何指定并注册模型顾问约束检查。在 newCheck 函数中,Advisor.authoring.createBlockConstraintCheck 函数使用 createConstraints 函数创建的约束来创建 ModelAdvisor.check 对象 rec

function newCheck()

    rec = Advisor.authoring.createBlockConstraintCheck(...
    'mathworks.check_0001',...
    'Constraints',@createConstraints);

    rec.Title = 'Example1: Check block parameter constraints';
    rec.TitleTips = 'Example check block parameter constraints';

    mdladvRoot = ModelAdvisor.Root;
    mdladvRoot.register(rec);

 
end

function constraints = createConstraints()

    c1=Advisor.authoring.PositiveBlockParameterConstraint;
    c1.ID='ID_1';
    c1.BlockType='Constant';
    c1.ParameterName='Value';
    c1.SupportedParameterValues={'1'};
    c1.ValueOperator='eq';

    c2=Advisor.authoring.PositiveBlockParameterConstraint;
    c2.ID='ID_2';
    c2.BlockType='Gain';
    c2.ParameterName='Gain';
    c2.SupportedParameterValues={'1'};
    c2.ValueOperator='gt';

    constraints = {c1,c2};

end

输入参数

全部折叠

模型顾问检查的名称,指定为字符向量

示例: 'com.mathworks.sample.Check1'

约束创建函数,指定为函数句柄。

示例: @createConstraints

输出参量

全部折叠

模型顾问检查,以 ModelAdvisor.check 对象的形式返回

版本历史记录

在 R2018a 中推出