Main Content

Advisor.authoring.createBlockConstraintCheck

Create Model Advisor check with block constraints

Description

example

check_obj = Advisor.authoring.createBlockConstraintCheck(check_ID,'Constraints',@handle) creates a ModelAdvisor.check object, check_obj, assigns it the identifier check_ID, and specifies block constraints in the constraints creation function @handle.

check_obj = Advisor.authoring.createBlockConstraintCheck(check_ID) creates a ModelAdvisor.check object, check_obj, and assigns it the identifier check_ID. Use the Advisor.authoring.generateBlockConstraintsDataFile function to create the block constraints data file. Specify the block constraints data file as an input parameter to the ModelAdvisor.check object using the setInputParameters function. For more information, see Advisor.authoring.generateBlockConstraintsDataFile.

Note

The ModelAdvisor.Check object created by Advisor.authoring.createBlockConstraintCheck does not support setting exclusions.

Examples

collapse all

This example shows how to specify and register a Model Advisor constraint check. In the function newCheck, the Advisor.authoring.createBlockConstraintCheck function creates the ModelAdvisor.check object rec using the constraints created by the function createConstraints.

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

Input Arguments

collapse all

Name of model advisor check, specified as a character vector

Example: 'com.mathworks.sample.Check1'

Constraints creation function, specified as a function handle.

Example: @createConstraints

Output Arguments

collapse all

Model Advisor check, returned as a ModelAdvisor.check object

Introduced in R2018a