Main Content

Custom Constraints

If the constraint you need cannot be created with the built-in attributes, you can create your custom constraint by writing your own MATLAB expression. To create a custom constraint:

  1. Launch Constraint Manager.

  2. Click Create Constraint.

  3. In the Custom Constraint section, enter a valid MATLAB expression in the MATLAB Expression field.

    You can use the value token to parameterize the expression. During validation, the evaluated value of the parameter replaces the value token. For example, if the MATLAB expression for a constraint is value > 100 and is associated with the Edit type mask parameter, Parameter1, the MATLAB expression evaluates as Parameter1 > 100. This helps in assigning the constraint to multiple parameters.

    For example, to set a custom constraint for a Gain block with an edit mask parameter that must accept only even numbers, in the MATLAB Expression enter the MATLAB command:

    "mod(value,2) ==0"

  4. Write the error message for your custom constraint in the Error Message field.

  5. Click Apply.

Related Topics