|On this page…|
This example shows how to estimate lookup table values from time-domain input-output (I/O) data.
In this example, you use the I/O data in lookup_regular.mat to estimate the values of a lookup table. The MAT-file includes the following variables:
xdata1 — Consists of 63 uniformly-sampled input data points in the range [0,6.5].
ydata1 — Consists of output data corresponding to the input data samples.
time1 — Time vector.
You use the I/O data to estimate the lookup table values in the lookup_regular Simulink® model. The lookup table in the model contains ten values, which are stored in the MATLAB® variable table. The initial table values comprise a vector of 0s. To learn more about how to model a system using lookup tables, see Guidelines for Choosing a Lookup Table in the Simulink documentation.
To estimate the lookup table values, you must first configure a Control and Estimation Tools Manager project.
Open the lookup table model by typing the following command at the MATLAB prompt:
This command opens the Simulink model, and loads the estimation data into the MATLAB workspace.
In the Simulink model, select Analysis > Parameter Estimation to open a new project named lookup_regular in the Control and Estimation Tools Manager GUI.
After you configure a project for parameter estimation, as described in Configuring a Project for Parameter Estimation, use the following steps to estimate the lookup table values.
Import the I/O data, xdata1 and ydata1, and the time vector, time1, into the Control and Estimation Tools Manager GUI. For more information, see Import Data (GUI).
Run an initial simulation to view the I/O data, simulated output, and the initial table values. To do so, type the following commands at the MATLAB prompt:
sim('lookup_regular') figure(1); plot(xdata1,ydata1, 'm*', xout, yout,'b^') hold on; plot(linspace(0,6.5,10), table, 'k', 'LineWidth', 2); legend('Measured data','Initial simulation data','Initial table values');
The x- and y-axes of the figure represent the input and output data, respectively.
Select the table values to estimate.
In the Control and Estimation Tools Manager GUI, select the Variables node under the Estimation Task node.
Click Add to open the Select Parameters dialog box, which shows the Simulink model parameters.
Select table, and click OK to add the table values to the Estimated Parameters tab.
The Default settings area of the GUI displays the default settings for the table values. The Value field displays the initial table values, which comprise a vector of ten 0s.
Select the Estimation node, and click New to add a New Estimation node.
Select the New Estimation node. In the Parameters tab, select the Estimate check box to specify the lookup table values, table, for estimation.
In the Data Sets tab of the New Estimation node, select the Selected check box to specify the estimation data set.
Estimate the table values using the default settings.
In the Estimation tab of the New Estimation node, click Start to start the estimation.
The Control and Tools Manager GUI updates at each iteration, and provides information about the estimation progress. After the estimation completes, the Control and Estimation Tools Manager GUI looks similar to the following figure.
Select the Parameters tab in the New Estimation node to view the estimated table values, which appear in the Value field.
After you estimate the table values, as described in Estimating the Table Values Using Default Settings, you must use another data set to validate that you have not overfitted the model. You plot and examine the following plots to validate the estimation results:
Measured and simulated data plots
To validate the estimation results:
Import the validation I/O data, xdata2 and ydata2, and time vector, time2, in the Control and Estimation Tools Manager GUI.
This project also contains the Residuals plot already configured in the Select plot types area of the GUI, as shown in the next figure. For more information on how to configure this plot, see Compare Measured and Simulated Responses.
Plot and examine the residuals:
Select the New Validation node under the Validation node.
In the Options area, select Validation Data from the Validation data set drop-down list.
Click Show Plots to open the residuals plot.
The residuals, which show the difference between the simulated and measured data, lie in the range [-0.15,0.15]— within 15% of the maximum output variation. This indicates a good match between the measured and the simulated table data values.
Plot and examine the estimated table values against the validation data set and the simulated table values by typing the following commands at the MATLAB prompt.
sim('lookup_regular') figure(2); plot(xdata2,ydata2, 'm*', xout, yout,'b^') hold on; plot(linspace(0,6.5,10), table, 'k', 'LineWidth', 2)
The plot shows that the table values, displayed as the black line, match both the validation data and the simulated table values. The table data values cover the entire range of input values, which indicates that all the lookup table values have been estimated.