Main Content

Define Constraint Values for Parameters in MATLAB Code Files

To specify parameters as variables for analysis, you can use the Parameter Table or define parameter configurations in a MATLAB® code file. You can also export parameter configuration files from the Parameter Table. For more information, see Store Parameter Constraints in MATLAB Code Files.

This example shows how to define parameter configurations in a MATLAB code file. For an example that shows how to define these parameter configurations using the Parameter Table, see Define Constraint Values for Parameters.

Template Parameter Configuration File

The Simulink® Design Verifier™ software provides an annotated template that you can use as a starting point:


To create a parameter configuration file, make a copy of the template and edit the copy. The comments in the template explain the syntax for defining parameter configurations.

To associate the parameter configuration file with your model before analyzing the model, in the Configuration Parameters dialog box, on the Design Verifier > Parameters pane, enter the file name in the Parameter configuration file field.

Syntax in Parameter Configuration Files

Specify parameter configurations using a structure whose fields share the same names as the parameters that you treat as input variables.

For example, suppose you want to constrain the Gain and Constant value parameters, m and b, which appear in the following model:

The PreLoadFcn callback function defines m and b in the MATLAB workspace when you open the model:

  • m is set to 5.

  • b is a Simulink.Parameter object of type int8 whose value is set to 5.

In your parameter configuration file, specify constraints for m and b:

params.b = int8([4 10]);
params.m = {};

This file specifies:

  • b is an 8-bit signed integer from 4 to 10. The constraint type must match the type of the parameter b in the MATLAB workspace, int8, in this example.

  • m is not constrained to any values.

Specify points using the Sldv.Point constructor, which accepts a single value as its argument. Specify intervals using the Sldv.Interval constructor, which requires two input arguments, i.e., a lower bound and an upper bound for the interval. Optionally, you can provide one of the following values as a third input argument that specifies inclusion or exclusion of the interval endpoints:

  • '()' — Defines an open interval.

  • '[]' — Defines a closed interval.

  • '(]' — Defines a left-open interval.

  • '[)' — Defines a right-open interval.


By default, Simulink Design Verifier considers an interval to be closed if you omit this argument.

The following example constrains m to 3 and b to any value in the closed interval [0, 10]:

params.m = Sldv.Point(3);
params.b = Sldv.Interval(0, 10);

If the parameters are scalar, you can omit the constructors and instead specify single values or two-element vectors. For example, you can alternatively specify the previous example as:

params.m = 3;
params.b = [0 10];


To indicate no constraint for an input parameter, specify params.m = {} or params.m = []. The analysis treats this parameter as free input.

You can specify multiple constraints for a single parameter using a cell array. In this case, the analysis combines the constraints using a logical OR operation.

The following example constrains m to either 3 or 5 and constrains b to any value in the closed interval [0, 10]:

params.m = {3, 5};
params.b = [0 10];

You can specify several sets of parameters by expanding the size of your structure. For example, the following example uses a 1-by-2 structure to define two sets of parameters:

params(1).m = {3, 5};
params(1).b = [0 10];

params(2).m = {12, 15, Sldv.Interval(50, 60, '()')};
params(2).b = 5;

The first parameter set constrains m to either 3 or 5 and constrains b to any value in the closed interval [0, 10]. The second parameter set constrains m to either 12, 15, or any value in the open interval (50, 60), and constrains b to 5.