Main Content

Specify Parameters for Design Exploration

This topic shows how to select parameters of a Simulink® model for design exploration in the Sensitivity Analyzer. After you select the parameters, you generate parameter samples by varying the parameter values in a specific range, and evaluate your design requirements for each combination of parameter values.

Add Model Parameters as Variables

The software can only evaluate variables that are in use by the model. Create variables in the MATLAB® or model workspace, and specify your Simulink model or block parameters using these variables. If you have already specified model parameters as variables, see Select Parameters for Design Exploration.

In this figure, the Gain parameter of a Gain block is specified as a numerical value.

Gain Block Parameter dialog box with Gain specified as 0.8

To evaluate design requirements using the Gain parameter, specify it as variable gain1:

  1. Create the variable gain1 in one of the following ways:

  2. Specify the block parameter as variable gain1 in the Gain block dialog box.

    Gain Block Parameter dialog box with Gain specified as gain1

You can now select gain1 for evaluation. See, Select Parameters for Design Exploration.

 Specify Independent Parameters

Select Parameters for Design Exploration

In the Sensitivity Analyzer, in the Sensitivity Analysis tab, click Select Parameters to open the Select model variables dialog box.

Use this dialog box to select parameters to vary. The table lists the variables that the model uses to set block parameter values. The variables can reside in the model workspace, the base workspace, or a data dictionary.

Select variables by checking the box next to each variable. In Parameter Estimator, you can specify whether a parameter is continuous or discrete.

  • Select Continuous to specify a continuously variable parameter.

  • Select Discrete to specify a parameter whose values during optimization are limited to a discrete, finite set. (since R2023a)

If your model contains many variables, filter the list by typing in the Filter by variable name field. The Used By column lists all blocks in the model that use the variable. When a variable is used in more than one block, all blocks are listed. To highlight blocks in the model that use the variable, click the block name. When you have completed your selections, click OK.

The continuous variables that you select must have a numeric value that uses the data type double. Discrete variables can take numeric or string values. If the value of a variable does not meet these conditions, use these techniques:

  • To select a single element, a subset of a matrix or array variable, or a structure, in the Specify expression indexing if necessary field, enter an expression that resolves to a numeric scalar value and press Enter key. For example, if A is a vector, enter A(3) to specify the third entry in A. If A is a structure and the scalar parameter you want to vary is the Value field of that structure, enter A.Value. The indexed variable appears in the variable list.

  • To use a variable of a numeric data type other than double, convert the variable to a Simulink.Parameter object, which separates a parameter value from its data type. Set the Value property to a default double number, and use the DataType property to control the data type.

  • To use one cell of a cell array, for example, enter myCells{3} to specify the third entry in myCells where myCells is a cell array.

  • To use a Simulink.Parameter object:

    • If the object has a one-dimensional value, directly select the object from the variable list and click OK.

    • If the object has a multidimensional value and you want to use all the values, directly select the object from the variable list. If you want to use a subset of the values, in the Specify expression indexing if necessary field, enter an expression using the indices corresponding to those values and press the Enter key. For example, if param is a Simulink.Parameter object and you want to select the second value, enter param(2). The indexed variable appears in the variable list. You can select it and click OK.

    • If the value of the object is a structure, in the Specify expression indexing if necessary field, enter an expression that accesses the required field value and press the Enter key. For example, if param is a Simulink.Parameter object and the parameter you want to vary is the value of a field field1, enter param.field1. The variable appears in the variable list. You can select it and click OK.

    Note that when you select a Simulink.Parameter object as a varying parameter, its Min and Max properties do not get automatically transferred.

You cannot use mathematical expressions such as a + b. Sometimes, models have parameters that are not explicitly defined in the model itself. For example, a gain k could be defined in the MATLAB workspace as k = a + b, where a and b are not defined in the model but k is used. To add these independent parameters, see Add Model Parameters as Variables.

Related Topics