Documentation Center |
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.
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.
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 | K_{t} is the torque gain of the motor, represented by Kt in the model. t_{d} 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. |
Input | U |
Output | T |
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. T_{hardstop} 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. |
Input | T |
Output | θ |
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:
To specify parameters and estimation data:
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.
Specify parameters for estimation.
Select the Variables node under the Estimation Task node.
Click Add.
This action opens the Select Parameters dialog box, which shows the model parameters for the Simulink model.
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.
Select the Estimation node, and click New.
This action adds a New Estimation node under the Estimation node.
Select the New Estimation node.
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.
Specify data for estimation by checking the Selected check box for Estim_Data_Prep in the Data Sets tab.
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.
Create plots to view the estimation results.
Select the Views node under the Estimation node, and click New.
This action creates a New View node under the Views node.
Select the New View node.
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.
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.
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.
View the estimated parameter values in the Value column of the Parameters tab.
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.
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.
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.
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:
Select the Parameters tab of the New Estimation node.
Specify the minimum value for each parameter by double-clicking the corresponding Minimum cell, and replacing -Inf with 0.
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.
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.
View the estimated parameter values in the Value column of the Parameters tab.
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.
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.
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:
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.
Plot the measured and simulated response, and residuals.
Select the Validation node, and click New.
This action creates a New Validation node.
Select the New Validation node.
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.
In the Options area, select the Plot 1, and Plot 2 check boxes.
Select Validation Data1 from the Validation data set drop-down list.
The Validation Setup tab resembles the next figure.
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.
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.
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.
Save the Control and Estimation Tools Manager project.
In the Control and Estimation Tools Manager GUI, select File > Save.
This action opens the Save Projects dialog box.
In the Save Projects dialog box, click OK.
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.