Documentation Center

  • Trial Software
  • Product Updates

Estimate Parameters from Measured Data (GUI)

About This Tutorial

Objectives

In this tutorial, you learn how to estimate parameters of a single-input single-output (SISO) Simulink® model from measured input and output (I/O) data.

    Note:   Simulink Design Optimization™ software estimates parameters from real, time-domain data only.

You learn to perform the following tasks using the GUI:

  • Load a saved project containing data.

  • Estimate model parameters using default settings.

  • Validate the model, and refine the estimation results.

About the Model

In this tutorial, you use the spe_engine_throttle1 Simulink model. This model represents an engine throttle system, as shown in the next figure.

The throttle system controls the flow of air and fuel mixture to the engine cylinders. The throttle body contains a butterfly valve which opens when a driver presses the accelerator pedal. Opening this valve increases the amount of fuel mixture entering the cylinders, which increases the engine speed. A DC motor controls the opening angle of the butterfly valve in the throttle system. The models for these components are described in Motor Subsystem, and Throttle Subsystem.

The input to the throttle system is the motor current (in amperes), and the output is the angular position of the butterfly valve (in degrees).

Motor Subsystem.  The Motor subsystem contains the DC motor model. To open the model, double-click the corresponding block.

The following table describes the variables, parameters, equation, input, and output of the Motor subsystem.

Variables

U is the input current to the motor.

T is the torque applied by the motor.

Parameters

Kt is the torque gain of the motor, represented by Kt in the model.

td is the input time delay of the motor, represented by input_delay in the model.

Equation

The torque applied by the motor is described in the following equation:

where t is time.
InputU
OutputT

Throttle Subsystem.  The Throttle subsystem contains the butterfly valve model. To open the model, right-click the corresponding block, and select Mask > Look Under Mask.

The Hard Stops block models the valve angular position limit of 15° to 90°.

The following table describes the variables, parameters, states, differential equations, inputs, and outputs of the Throttle subsystem.

Variables

T is the torque applied by the DC motor.

θ is the angular position of the valve, represented by x in the model.

Thardstop is the torque applied by the hard stop.

Parameters

J is the inertia.

c is the viscous friction.

k is the spring constant.

States

is the angular position.

is the angular velocity.

Equations

The mathematical system for the butterfly valve is described in the following equation:

where , with initial conditions , and .

The torque applied by the Hard Stops block is described in the following equation:

where K is the gain of the Hard Stops block.
InputT
Outputθ

Estimating Model Parameters Using Default Estimation Settings

Overview of the Estimation Process

Simulink Design Optimization software uses optimization techniques to estimate model parameters. In each optimization iteration, the model is simulated with the current parameter values. The error between the simulated and measured output is computed and minimized. The estimation is complete when the optimization method finds a local minimum.

You perform the following tasks to estimate the model parameters:

    Note:   The Simulink model must remain open to perform parameter estimation tasks.

Specifying Parameters and Estimation Data

To specify parameters and estimation data:

  1. Load the preconfigured project spe_engine_throttle1p.mat by clicking hereclicking here.

    This MAT-file contains the estimation data. To learn more about the data and how to prepare it, see Prepare Data for Parameter Estimation (GUI).

    The Control and Estimation Tools Manager GUI opens as shown in the next figure.

  2. Specify parameters for estimation.

    1. Select the Variables node under the Estimation Task node.

    2. Click Add.

      This action opens the Select Parameters dialog box, which shows the model parameters for the Simulink model.

    3. Select the parameters J, c, input_delay, and k by pressing the Ctrl key while clicking each name, and then click OK.

      This action adds the selected parameters to the Estimated Parameters tab.

        Tip   When estimating a large number of parameters, you can select a subset of parameters to estimate. For more information, see the example Inverted Pendulum Parameter Estimation.

    4. Select the Estimation node, and click New.

      This action adds a New Estimation node under the Estimation node.

    5. Select the New Estimation node.

    6. In the Parameters tab, select the Estimate check box for all the parameters.

      This action specifies the selected parameters for estimation.

      The Parameters tab, as shown in the previous figure, displays the following information for each parameter:

      • Value: Current parameter value. By default, it is equal to the value specified in the Simulink model.

        During estimation, the optimization method might change a parameter value to minimize the error between the measured and simulated output.

      • Initial Guess: Initial parameter value. By default, it is equal to the value in the Value field and is used at the start of estimation.

      • Minimum and Maximum: Bounds on the parameter value. By default, they are set to -Inf, and +Inf, respectively. This means that the optimization method searches for a solution in the range [-Inf, +Inf].

      • Typical Value: Order of magnitude of the parameter value. By default, it is equal to the value in the Initial Guess field.

  3. Specify data for estimation by checking the Selected check box for Estim_Data_Prep in the Data Sets tab.

Validating Model Parameters

After you specify parameters and data for estimation, as described in Specifying Parameters and Estimation Data, estimate the parameters and analyze the results to determine if the model needs to be refined.

  1. Create plots to view the estimation results.

    1. Select the Views node under the Estimation node, and click New.

      This action creates a New View node under the Views node.

    2. Select the New View node.

    3. In the View Setup tab, select the following plots from the drop-down list in the Plot Type column:

      • For Plot 1, select Measured and simulated.

      • For Plot 2, select Cost function.

    4. In the Options area, select the Plot 1 and Plot 2 check boxes, and click Show Plots.

      Clicking Show Plots opens the following figures:

      • New View - Plot 1 (Measured and simulated): Displays the measured output data Estim_Prep_Data. During estimation, this plot updates to display the simulated response at each iteration.

      • New View - Plot 2 (Cost function): Displays the error between the measured and simulated output, computed at each iteration. By default, the error is computed using sum- of- squared- errors, which is a least-squares method.

  2. Estimate the parameters by selecting the Estimation tab of the New Estimation node, and clicking Start.

    The Estimation tab updates at each iteration, and provides information about the estimation progress. When the estimation completes, the Estimation tab resembles the next figure.

      Note:   The results of the optimization may differ slightly because of different numerical precision across platforms.

    The table displays the following information for each iteration:

    • Cost Function: Error between the simulated and measured output.

      During estimation, the default optimization method Nonlinear least squares, lsqnonlin, minimizes the cost function by changing the parameter values. As shown in the previous figure, the cost function decreases by only 27% from 2.69e5 to 1.95e5.

    • Step Size: Displacement of the optimization method in the current search direction when minimizing the cost function. A final value close to zero indicates that the method has found a local minimum. As shown in the previous figure, the final step size in the last iteration is 5.96e-7.

  3. View the estimated parameter values in the Value column of the Parameters tab.

  4. Examine the simulated response plot to see how well the simulated output matches the measured output.

    The simulated response with the estimated parameters is shown in blue on the New View - Plot 1 (Measured and simulated) plot, and significantly differs from the measured data. This difference indicates that the estimated parameters are not accurate.

  5. Examine the cost function plot to see how the cost function changes during the estimation.

    The cost function values shown in step 2 are plotted on the New View - Plot 2(Cost function) plot. The cost function decreases by only 27% from its initial value, and in conjunction with the measured and simulated output plot, indicates that the estimated parameters are not accurate.

To improve the estimation results, you apply bounds on the parameter values, as described in Improving Estimation Results Using Parameter Bounds.

Improving Estimation Results Using Parameter Bounds

Strategy for Improving the Estimation Results

Analyzing the Measured and Simulated and Cost function plots, as described in Validating Model Parameters, you see that the model parameters estimated using the default estimation settings are not accurate. You must run additional estimations to improve the accuracy of the model. There are several techniques to improve the accuracy of the estimated parameters. For more information, see How to Specify Estimation Options in the GUI.

In this portion of the tutorial, you improve the results by specifying bounds on parameter values. This technique restricts the region in which the optimization method searches for a local minima.

Based on physical insight, you know the following characteristics of the engine throttle system:

  • All the parameter values are positive.

  • Maximum time delay of the system, represented by input_delay, is 0.1 s.

Therefore, you specify 0 as the minimum value for all parameters, and 0.1 as the maximum value of input_delay.

After you estimate the parameters, analyze the results using the Measured and Simulated and Cost function plots.

How to Specify Parameter Bounds

You must have already estimated the parameters using default settings, as described in Estimating Model Parameters Using Default Estimation Settings.

To improve the estimation results by specifying parameter bounds:

  1. Select the Parameters tab of the New Estimation node.

  2. Specify the minimum value for each parameter by double-clicking the corresponding Minimum cell, and replacing -Inf with 0.

  3. Specify the maximum value for input_delay by double-clicking the corresponding Maximum cell and replacing +Inf with 0.1.

    The Parameters tab resembles the next figure.

  4. Select the Estimation tab, and click Start.

    The Estimation tab updates at each iteration, and provides information about the estimation progress. When the estimation completes, the Estimation tab resembles the next figure.

      Note:   The results of the optimization may differ slightly because of different numerical precision across platforms.

    The cost function decreases by 99% from 1.95e5 to 239.94. The final step size 8.75e-7 is close to 0, which indicates that the optimization method has found a local minimum.

  5. View the estimated parameter values in the Value column of the Parameters tab.

  6. Examine the simulated response plot to see how well the simulated output matches the measured output.

    The simulated response plot, shown in blue on the New View - Plot 1 (Measured and simulated) plot, is overlaid on the measured output data. The simulated output closely matches the measured data.

  7. Examine the cost function plot to see how the cost function changes during the estimation.

    The cost function values shown in step 4 are plotted on the New View - Plot 2(Cost function) plot. The cost function also decreases by 99% from its initial value, and in conjunction with the measured and simulated response plot indicates a good fit of the simulated response with the measured data.

Validating Estimated Model Parameters

After you estimate the model parameters, as described in Improving Estimation Results Using Parameter Bounds, validate the model using another data set (validation data). A good match between the simulated response and the validation data indicates that you have not overfitted the model.

To validate the estimated parameters using a validation data set:

  1. Load the preconfigured project spe_engine_throttle1_importValData1.mat by clicking hereclicking here.

    This MAT-file contains a validation data set already imported into the GUI, and the estimated parameters as described in Improving Estimation Results Using Parameter Bounds.

      Tip   To learn how to import data and time vector into the Control and Estimation Tools Manager GUI, see Importing Data into the GUI.

    The Control and Estimation Tools Manager GUI now has a node that contains the validation data, as shown in the next figure.

    The validation data contains the input data, output data and time vector in the MATLAB® variables input2, position2 and time2 respectively.

  2. Plot the measured and simulated response, and residuals.

    1. Select the Validation node, and click New.

      This action creates a New Validation node.

    2. Select the New Validation node.

    3. In the Validation Setup tab, select the following plots in the Plot Type column.

      • For Plot 1, select Measured and simulated.

      • For Plot 2, select Residuals.

    4. In the Options area, select the Plot 1, and Plot 2 check boxes.

    5. Select Validation Data1 from the Validation data set drop-down list.

      The Validation Setup tab resembles the next figure.

    6. Click Show Plots.

      This action opens the following figures:

      • New Validation - Plot 1 (Measured and simulated): Displays the validation data and simulated response.

      • New Validation - Plot 2(Residuals): Displays the difference between the measured data and simulated response.

  3. Examine the simulated response plot to see how well the simulated output matches the validation data.

    The simulated response, as shown in blue on the New Validation - Plot 1 (Measured and simulated) plot, is overlaid on the measured output data, and closely matches the measured data Validation Data 1.

  4. Examine the residuals plot to compare the difference between the simulated response and measured data.

    The difference between the simulated and measured data, as shown in the New Validation - Plot 2(Residuals) plot, varies between 2 and -2.5. The residuals lie within 6% of the maximum output variation, and do not display any systematic patterns. This indicates a good fit between the simulated output and measured data.

  5. Save the Control and Estimation Tools Manager project.

    1. In the Control and Estimation Tools Manager GUI, select File > Save.

      This action opens the Save Projects dialog box.

    2. In the Save Projects dialog box, click OK.

    3. In the Save Projects window, specify the name of the project in the File name field, and click Save.

      This action saves the project as a MAT-file.

      Tip   You can load a project by selecting File > Load in the Control and Estimation Tools Manager GUI. To view the estimated parameter values, select the Parameters tab of New Estimation node.

Was this topic helpful?