| Products & Services | Solutions | Academia | Support | User Community | Company |
| Download Product Updates | | | Get Pricing | | | Trial Software |
| Documentation → Simulink Design Optimization |
| Contents | Index |
| Learn more about Simulink Design Optimization |
| On this page… |
|---|
Specifying Data for Parameter Estimation |
This section describes how to use the GUI to estimate parameters. After you import the transient data, as described in Importing Data into the GUI, you must create an estimation task and configure the estimation settings. To create a container that stores the estimation settings:
In the Control and Estimation Tools Manager, right-click the Estimation node in the workspace directory tree and select New.
Select the New Estimation node.
The Control and Estimation Tools Manager now resembles the next figure.

To specify a data set for estimation, you must have already imported the data in the GUI and created an Estimation Task, as described in Creating an Estimation Task. If your data contains noise or outliers, you must also preprocess the data, as described in Preprocessing Data in the GUI.
After you select the New Estimation node, the Data Sets tab appears. Here you select the data set that you want to use in the estimation.
Select the Selected check box to the right of the New Data data set.

Note If you imported multiple data sets, you can select them for estimation by selecting the check box to the right of each desired data set. When using several data sets, you increase the estimation precision. However, you also increase the number of required simulations: for N parameters and M data sets, there are M*(2N+1) simulations per iteration. |
Then, specify the weight of each output from this model by setting the Weight column in the Output data weights table.
The relative weights are used to place more or less emphasis on specific output variables. The following are a few guidelines for specifying weights:
Use less weight when an output is noisy.
Use more weight when an output strongly affects parameters.
Use more weight when it is more important to accurately match this model output to the data.
Simulink Design Optimization software lets you estimate scalar, vector and matrix parameters. Estimating model parameters is an iterative process. Often, it is more practical to estimate a small group of parameters and use the final estimated values as a starting point for further estimation of parameters that are trickier. When you have a large number of parameters to estimate, select the parameters that influence the output the most to be estimated first. Making these sorts of choices involves experience, intuition, and a solid understanding of the strengths and limitations of your Simulink model.
After you estimate a subset of parameters and validate the estimated parameters, select the remaining parameters for estimation.
To select parameters for estimation:
In the Control and Estimation Tools Manager, select the Variables node in the workspace directory tree to open the Estimated Parameters pane.

In the Estimated Parameters pane, click Add to open the Select Parameters dialog box.

The dialog box lists all the variables in the model workspace and the MATLAB workspace that the model uses. You can use the mouse to select the parameters to estimate.
You can also enter parameters, separated by commas, in the Specify expression field of the Select Parameters dialog box. The parameters can be stored in one of the following:
Simulink software parameter object
Example: For a Simulink parameter object k, type k.value.
Structure
Example: For a structure S, type S.fieldname (where fieldname represents the name of the field that contains the parameter).
Cell array
Example: Type C{1} to select the first element of the C cell array.
MATLAB array
Example: Type a(1:2) to select the first column of a 2-by-2 array called a.
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 to the Select Parameters dialog box, see Specifying Parameter Dependency.
Select the last seven parameters: freq1, freq2, freq3, gain1, gain2, gain3, and mean_speed, and then click OK.
Note You need not estimate the parameters selected here all at once. You can first select all the parameters that you are interested in, and then later select the ones to estimate as described in the next step. |
The Control and Estimation Tools Manager now resembles the next figure.

To learn how to specify the settings in the Default settings area of the pane, see Specifying Initial Guesses and Upper/Lower Bounds.
In the New Estimation node of the Control and Estimation Tools Manager GUI, select the Parameters tab . In this pane, you select which parameters to estimate and the range of values for the estimation.
Select the parameters you want to estimate by selecting the check box in the Estimate column.
Enter initial values for your parameters in the Initial Guess column.
The default values in the Minimum and Maximum columns are -Inf and +Inf, respectively, but you can select any range you want. For more information, see Specifying Initial Guesses and Upper/Lower Bounds.
For this example, select gain1, gain2, gain3 and mean_speed for estimation and set gain1 to 10, gain2 to 100, gain3 to 50, and mean_speed to 500. Alternatively, use any initial values you like.
If you have good reason to believe a parameter lies within a finite range, it is usually best not to use the default minimum and maximum values. Often, there are computational advantages in specifying finite bounds if you can. It can be very important to specify lower and upper bounds. For example, if a parameter specifies the weight of a part, be sure to specify 0 as the absolute lower bound if better knowledge is unavailable.
The Control and Estimation Tools Manager now resembles the next figure.

After you select parameters for estimation in the Variables node of the Control and Estimation Tools Manager GUI, the Estimated Parameters tab in the Control and Estimation Tools Manager looks like the following figure.

For each parameter, use the Default settings pane to specify the following:
Initial guess — The value the estimation uses to start the process.
Minimum — The smallest allowable parameter value. The default is -Inf.
Maximum — The largest allowable parameter value. The default is +Inf.
Typical value — The average order of magnitude. If you expect your parameter to vary over several orders of magnitude, enter the number that specified the average order of magnitude you expect. For example, if your initial guess is 10, but you expect the parameter to vary between 10 and 1000, enter 100 (the average of the order of magnitudes) for the typical value.
You use the typical value in two ways:
To scale parameters with radically different orders of magnitude for equal emphasis during the estimation. For example, try to select the typical values so that
![]()
or
![]()
To put more of less emphasis on specific parameters. Use a larger typical value to put more emphasis on a parameter during estimation.
Sometimes parameters in your model depend on independent parameters that do not appear in the model. The following steps give an overview of how to specify independent parameters for estimation:
Add the independent parameters to the model workspace (along with initial values).
Define a Simulation Start function that runs before each simulation of the model. This Simulation Start function defines the relationship between the dependent parameters in the model and the independent parameters in the model workspace.
The independent parameters now appear in the Select Parameters dialog box. Add these parameters to the list of parameters to be estimated.
Caution Avoid adding independent parameters together with their corresponding dependent parameters to the lists of parameters to be estimated. Otherwise the estimation could give incorrect results. For example, when a parameter x depends on the parameters a and b, avoid adding all three parameters to the list. |
For an example of how to specify independent parameters, see Example: Specifying Independent Parameters for Estimation.
Assume that the parameter Kint in the model srotut1 is related to the parameters x and y according to the relationship Kint=x+y. Also assume that the initial values of x and y are 1 and -0.7 respectively. To estimate x and y instead of Kint, first define these parameters in the model workspace. To do this:
At the MATLAB prompt, type
srotut1
This opens the srotut1 model window.
Select View > Model Explorer from the srotut1 window to open the Model Explorer window.
In the Model Hierarchy tree, select the srotut1 > Model Workspace node.

Select Add > MATLAB Variable to add a new variable to the model workspace. A new variable with a default name Var appears in the Contents of: Model Workspace pane.
Double-click Var to make it editable and change the variable name to x. Edit the initial Value to 1.
Repeat steps 4 and 5 to add a variable y with an initial value of -0.7. The Model Explorer window should resemble the following figure.

To add the Simulation Start function defining the relationship between Kint and the independent parameters x and y, select File > Model Properties in the Simulink model for srotut1.
In the Model Properties window, click the Callbacks tab.
To enter a Simulation start function in StartFcn*, type the name of a new M-file, for example, srotut1_start.
Create a new M-file with this name. The contents of the M-file should define the relationship between the parameters in the model and the parameters in the workspace. For this example, the M-file should resemble the following:
wks = get_param(gcs, 'ModelWorkspace')
x = wks.evalin('x')
y = wks.evalin('y')
Kint = x+y;
Note You must first use the get_param function to get the variables x and y from the model workspace before you can use them to define Kint. |
When you select parameters for estimation in the Variables node, x and y appear in the Select Parameters dialog box.

Often, sets of measured data are collected at various times and under different initial conditions. When you estimate model parameters using one data set and subsequently run another estimation with a second data set, your parameter values may not match. Given that the Simulink Design Optimization software attempts to find constant values for parameters, this is clearly a problem.
You can estimate the initial conditions using procedures that are similar to those you use to estimate parameters. You can then use these initial condition estimates as a basis for estimating parameters for your Simulink model. The Control and Estimation Tools Manager has an Estimated States pane that lists the states available for initial condition estimation. To learn how to estimate initial states, see Estimating Initial States.
After you select parameters for estimation, as described in Specifying Parameters to Estimate, you can specify initial conditions of states in your model. By default, the estimation uses initial conditions specified in the Simulink model. If you want to specify initial conditions other than the defaults, use the State Data tab. You can select the State Data tab in the New Data node under the Transient Data node in the workspace directory tree.

To specify the initial condition of a state for the engine_idle_speed model:
Select the Data cell associated with the state.
Enter the initial conditions. In this example, enter -0.2 for State - 1 of the engine_idle_speed/Transfer Fcn. For State - 2, enter 0.

You can choose the plot type from the Plot Type drop-down list. The following types of plots are available for viewing and evaluating the estimation:
Cost function — Plot the cost function values.
Measured and simulated — Plot empirical data against simulated data.
Parameter sensitivity — Plot the rate of change of the cost function as a function of the change in the parameter. That is, plot the derivative of the cost function with respect to the parameter being varied.
Parameter trajectory — Plot the parameter values as they change.
Residuals — Plot the error between the experimental data and the simulated output.
Before you begin estimating the parameters, you must create the plots for viewing the progress of the estimation.
Note An estimation must be created before creating views. Otherwise, the Options table will be empty. To learn more, see Creating an Estimation Task. |
To create plots for viewing the estimation progress, follow the steps below:
Right-click the Views node in the Control and Estimation Tools Manager and select New.
In the workspace directory tree, select New View to open the View Setup pane.

In the Select plot types table, select the Plot Type from the drop-down list. In this example, select Cost function.

Select Measured and simulated as the Plot Type for Plot 2. This plot will be used in Performing Validation.
In the Options area, select the check-box for both Plot 1 and Plot 2.
Click Show Plots. This displays an empty cost function plot and a plot of the measured data.

When you perform the estimation, the plot updates automatically.
In the New Estimation node in the workspace directory tree, click the Estimation tab.

Click Estimation Options. This action opens the Options- New Estimation dialog box where you can specify the estimation method, algorithm options and cost function for the estimation.

The following sections describe the estimation method settings and cost function:
Both the Method and Algorithm options define the optimization method. Use the Optimization method area of the Options dialog box to set the estimation method and its algorithm.
![]()
For the Method option, the four choices are:
Nonlinear least squares (default) — Uses the Optimization Toolbox™ nonlinear least squares function lsqnonlin.
Gradient descent — Uses the Optimization Toolbox function fmincon.
Pattern search — Uses the pattern search method patternsearch. This option requires Genetic Algorithm and Direct Search Toolbox™ software.
Simplex search — Uses the Optimization Toolbox function fminsearch, which is a direct search method. Simplex search is most useful for simple problems and is sometimes faster than fmincon for models that contain discontinuities.
The following table summarizes the Algorithm options for the Nonlinear least squares and Gradient descent estimation methods:
| Method | Algorithm Option | Learn More |
|---|---|---|
| Nonlinear least squares |
| In the Optimization Toolbox documentation, see: |
| Gradient descent |
| In the Optimization Toolbox documentation, see: |
Specify termination options in the Optimization options area.

Several options define when the optimization terminates:
Diff max change — The maximum allowable change in variables for finite-difference derivatives. See fmincon in the Optimization Toolboxdocumentation for details.
Diff min change — The minimum allowable change in variables for finite-difference derivatives. See fmincon in the Optimization Toolbox documentation for details.
Parameter tolerance — Optimization terminates when successive parameter values change by less than this number.
Maximum fun evals — The maximum number of cost function evaluations allowed. The optimization terminates when the number of function evaluations exceeds this value.
Maximum iterations — The maximum number of iterations allowed. The optimization terminates when the number of iterations exceeds this value.
Function tolerance — The optimization terminates when successive function values are less than this value.
By varying these parameters, you can force the optimization to continue searching for a solution or to continue searching for a more accurate solution.
At the bottom of the Optimization options pane is a group of additional optimization options.
![]()
Additional options for optimization include:
Display level — Specifies the form of the output that appears in the MATLAB command window. The options are Iteration, which displays information after each iteration, None, which turns off all output, Notify, which displays output only if the function does not converge, and Final, which only displays the final output. Refer to the Optimization Toolbox documentation for more information on what type of iterative output each method displays.
Gradient type — When using Gradient Descent or Nonlinear least squares as the Method, the gradients are calculated based on finite difference methods. The Refined method offers a more robust and less noisy gradient calculation method than Basic, although it does take longer to run optimizations using the Refined method.
The cost function is a function that estimation methods attempt to minimize. You can specify the cost function at the bottom of the Optimization options area.
![]()
You have the following options when selecting a cost function:
Cost function — The default is SSE (sum of squared errors), which uses a least-squares approach. You can also use SAE, the sum of absolute errors.
Use robust cost — Makes the optimizer use a robust cost function instead of the default least-squares cost. This is useful if the experimental data has many outliers, or if your data is noisy.
You can set several options to tune the results of the estimation. These options include the optimization methods and their tolerances.
To set options for estimation:
Select the New Estimation node in the workspace directory tree.
Click the Estimation tab.
Click Estimation Options to open the Options dialog box.
Click the Optimization Options tab and specify the options.

To optimize the response signals of a model, Simulink Design Optimization software runs simulations of the model.
To set options for simulation:
Select the New Estimation node in the workspace directory tree.
Click the Estimation tab.
Click Estimation Options to open the Options dialog box.

Click the Simulation Options tab and specify the options, as described in the following sections:
You can specify the simulation start and stop times in the Simulation time area of the Simulation Options tab.
![]()
By default, Start time and Stop time are automatically computed based on the start and stop times specified in the Simulink model.
To set alternative start and stop times for the optimization, enter them under Simulation time. This action overwrites the simulation start and stop times specified in the Simulink model.
Simulation Time for Data Sets with Different Time Lengths. Simulink Design Optimization software can simulate models containing empirical data sets of different time lengths. You can use experimental data sets for estimation that contain I/O samples collected at different time points.
The following example shows a single-input, two-output model for which you want to estimate the parameters.

The model uses two output data sets containing transient data samples for parameter estimation:
Output y1(t) at time points
.
Output y2(t) at time points
.
The simulation time t is computed as:
![]()
This new set ranges from tmin to tmax. The values tmin and tmax represent the minimum and maximum time points in t respectively.
When you run the estimation, the model is simulated over the time range t. Simulink extracts the simulated data for each output based on the following criteria:
Start time —
Typically, the start time in the Simulink model is set to 0.
For a nonzero start time, the simulated data corresponding to time
points before
for y1(t) and
for y2(t) are
discarded.
Stop time —
If the stop time
, the simulated
data corresponding to time points in t1 are extracted
for y1(t). Similarly, the simulated data for
time points in t2 are extracted for y2(t).
If the stop time
, the data spanning
time points
are discarded for both y1(t) and y2(t).
You can specify the solver in the Solver options area of the Simulation Options tab.

When running the simulation, the dynamic system is solved using one of several Simulink solvers. You can specify several solver options using the Solver options area in the Options dialog box. The Type of solver can be variable-step or fixed-step. Variable-step solvers keep the error within specified tolerances by adjusting the step-size the solver uses. Fixed-step solvers use a constant step-size. When your model's states are likely to vary rapidly, a variable-step solver is often faster. See the Simulink documentation for information about solvers.
Variable-Step Solvers. When you select Variable-step as the solver Type, you can choose any of the following as the Solver:
Discrete (no continuous states)
ode45 (Dormand-Prince)
ode23 (Bogacki-Shampine)
ode113 (Adams)
ode15s (stiff/NDF)
ode23s (stiff/Mod. Rosenbrock)
ode23t (Mod. stiff/Trapezoidal)
ode23tb (stiff/TR-BDF2)
Variable-Step Solver Options. When you select Variable-step as the Simulink solver Type, you can also set several other parameters that affect the step-size of the simulation:
Maximum step size — The largest step-size the solver can use during a simulation.
Minimum step size — The smallest step-size the solver can use during a simulation.
Initial step size — The step-size the solver uses to begin the simulation.
Relative tolerance — The largest allowable relative error at any step in the simulation.
Absolute tolerance — The largest allowable absolute error at any step in the simulation.
Zero crossing control — Set to on for the solver to compute exactly where the signal crosses the x-axis. This is useful when using functions that are nonsmooth and the output depends on when a signal crosses the x-axis, such as absolute values.
By default, the values for these options are automatically chosen. To choose your own values, enter them in the appropriate fields.
Fixed-Step Solvers. When you select Fixed-step as the solver Type, you can choose any of the following as the Solver:
Discrete (no continuous states)
ode5 (Dormand-Prince)
ode4 (Runge-Kutta)
ode3 (Bogacki-Shanpine)
ode2 (Heun)
ode1 (Euler)
When you select Fixed-step as the solver Type, you can also set Fixed step size, which determines the step-size the solver uses during the simulation. By default, a value for this option is automatically chosen.
You can specify the display options by clicking Display Options in the Estimation tab in the Control and Estimation tools Manager. This opens the following dialog box.

Clearing a check box implies that feature will not appear in the display table as the estimation progresses. To learn more about the display table, see Displaying Iterative Output in the Optimization Toolbox documentation.
![]() | Overview of Parameter Estimation | Estimating and Validating Parameters in the GUI | ![]() |

Learn more about Simulink through this collection of videos, articles, technical literature and the Getting Started with Simulink Guide.
| © 1984-2009- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |