Documentation Center

  • Trial Software
  • Product Updates

Prepare Data for Parameter Estimation (GUI)

About This Tutorial

Objectives

In this tutorial, you learn how to import, analyze, and prepare measured input and output (I/O) data for estimating parameters of a Simulink® model.

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

You learn to perform the following tasks using the GUI:

  • Import data from the MATLAB® workspace.

  • Analyze data quality using a time plot.

  • Select a subset of data for estimation.

  • Remove outliers.

  • Filter high-frequency noise.

  • Compute missing data using interpolation.

About the Sample Data

In this tutorial, you use spe_engine_throttle1.mat, which contains I/O data measured from an engine throttle system. The MAT-file includes the following variables:

  • input1 — Input data samples

  • position1 — Output data samples

  • time1 — Time vector

    Note:   The number of input and output data samples must be equal to the length of the corresponding time vector.

The engine 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 input to the throttle system is the motor current (in amperes), and the output is the angular position of the butterfly valve (in degrees).

spe_engine_throttle1 contains the Simulink model of the engine throttle system.

Configuring a Project for Parameter Estimation

To perform parameter estimation, you must first configure a Control and Estimation Tools Manager project.

  1. Open the engine throttle system model by typing the following at the MATLAB prompt:

    spe_engine_throttle1

    This command opens the Simulink model, and loads the data into the MATLAB workspace.

    Simulink Model of Engine Throttle System

  2. In the Simulink model window, select Analysis > Parameter Estimation.

    This action opens a new project named Project - spe_engine_throttle1 in the Control and Estimation Tools Manager GUI. This project contains the Estimation Task, as shown in the next figure.

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

Importing Data into the GUI

Importing Input Data and Time Vector

In this portion of the tutorial, you import measured I/O data into the Control and Estimation Tools Manager GUI. Importing data assigns the data to the corresponding model input and output signals.

The model input and output signals are designated with the Inport Input and Outport Position blocks respectively, as shown in the figure Simulink Model of Engine Throttle System. These blocks let you import I/O data into the GUI. To learn more about the blocks, see the Inport and Outport block reference pages in the Simulink documentation.

You must have already configured the parameter estimation project, as described in Configuring a Project for Parameter Estimation.

To import input data and time vector into the Control and Estimation Tools Manager GUI:

  1. In the Control and Estimation Tools Manger GUI, select Transient Data under the Estimation Task node, and click New.

    This action creates a New Data node under the Transient Data node.

  2. Select the New Data node.

  3. In the Input Data tab, select the Data cell for Channel - 1, and click Import.

    This action opens the Data Import dialog box.

  4. In the Data Import dialog box, select input1, and click Import.

    This action assigns the input data input1 to the model input signal spe_engine_throttle1/Input.

  5. Select the Time / Ts cell for Channel - 1.

  6. In the Data Import dialog box, select time1, and click Import.

    This action assigns the time vector to the model input signal spe_engine_throttle1/Input.

  7. In the Data Import dialog box, click Close.

Importing Output Data and Time Vector

To import output data and time vector into the Control and Estimation Tools Manager GUI:

  1. In the Control and Estimation Tools Manger GUI, select the Output Data tab of the New Data node.

  2. Select the Data cell for Channel - 1, and click Import.

    This action opens the Data Import dialog box.

  3. In the Data Import dialog box, select position1, and click Import.

    This action assigns the output data position1 to the model output signal spe_engine_throttle1/Position.

  4. Select the Time / Ts cell for Channel - 1.

  5. In the Data Import dialog box, select time1, and click Import.

    This action assigns the time vector to the model output signal spe_engine_throttle1/Position.

  6. In Data Import dialog box, click Close.

You have now imported the I/O data into the Control and Estimation Tools Manager GUI, and assigned the data to the corresponding model signals.

Analyzing Data

In this portion of the tutorial, you analyze the output data quality by viewing the data characteristics on a time plot. Based on the analysis, you decide whether to preprocess the data before estimating parameters. For example, if the data contains noise, you might want to filter the noise from the system dynamics before estimating parameters.

You must have already imported the data into the Control and Estimation Tools Manager GUI, as described in Importing Data into the GUI. If you have not imported the data, click hereclick here.

To plot the output data on a time plot, select the position1(:,1) cell in the Output Data tab, and click Plot Data.

This action plots the measured output data position1(:,1), as shown in the next figure.

The time plot shows the output data in response to a step input, as described in About the Sample Data. The plot shows a rapid decrease in the response after t = 0.5 s because the system is shut down. To focus parameter estimation on the time period when the system is active, you select the data samples between t = 0 s and t = 0.5 s, as described in Selecting Data for Estimation section of this tutorial.

The spikes in the data indicate outliers, defined as data values that deviate from the mean by more than three standard deviations. They may be caused by measurement errors or sensor problems. The response also contains noise. Before estimating model parameters from this data, you remove the outliers and filter the noise, as described in Removing Outliers, and Filtering Data sections of this tutorial.

    Tip   You can also plot the input data on a time plot by selecting the input1(:,1) cell in the Input Data tab, and clicking Plot Data.

Selecting Data for Estimation

Selecting Output Data

In this portion of the tutorial, you select a subset of I/O data for estimation. As described in Analyzing Data, the system is shut down at t = 0.5 s. To focus the estimation on the time period before t = 0.5 s, you exclude the data samples beyond t = 0.5 s. This operation selects the data between t = 0 s and t = 0.5 s for estimation.

You must have already imported the data into the Control and Estimation Tools Manager GUI, as described in Importing Data into the GUI. If you have not imported the data, click hereclick here.

To select the portion of data between t = 0 s and t = 0.5 s:

  1. In the Control and Estimation Tools Manager window, select the New Data node under the Transient Data node.

  2. Select the position1(:,1) cell in the Output Data tab, and click Pre-process.

    This action opens the Data Preprocessing Tool GUI.

    The Data Editing area of the Data Preprocessing Tool GUI shows the output data and time vector in the position1(:,1) and Time (seconds) columns, respectively. The Data Preprocessing Tool GUI lets you perform the following types of preprocessing operations:

    • Excluding data

    • Detrending and filtering data

    • Handling missing data

  3. To exclude the output data beyond t = 0.5 s:

    1. In the Exclusion Rules tab, select the Bounds check box.

    2. In the Exclude X field, where X corresponds to the time vector, select > from the drop-down list. Enter 0.5 in the adjacent field to specify the upper limit of the data to select for estimation.

      The Data Preprocessing Tool GUI resembles the next figure.

    3. Click Add.

      This action adds a new Dataset1 node under the Transient Data node in the Control and Estimation Tools Manager GUI. The Dataset1 node contains the modified output data position1(:,1)* in the Output Data tab.

      This operation also replaces the output data samples beyond t = 0.5 s in position1(:,1)* with NaNs. You can view the NaNs by selecting the Modified data tab in the Data Preprocessing Tool GUI, as shown in the next figure.

  4. To remove the NaNs:

    1. In the Control and Estimation Tools Manager GUI, select the Output Data tab of the Dataset1 node.

    2. Select the position1(:,1)* cell, and click Pre-process.

      This action updates the Data Preprocessing Tool GUI with the selected data position1(:,1)*.

    3. In the Missing Data Handling area, select the Remove rows where data is excluded or missing check box.

        Tip   You can view the results of this operation in the Modified data tab.

    4. In the Write results to area, select the existing dataset option.

    5. Click Add.

      The Update table data dialog box appears. Click Yes to overwrite the position1(:,1)* data set with the modified data.

  5. To plot the data, select the position1(:,1)* cell in the Output Data tab of the Dataset1 node, and click Plot Data.

    The selected output data from t = 0 s to t = 0.5 s is shown in the next figure.

Selecting Input Data

After you select the output data between t = 0 s and t = 0.5 s, as described in Selecting Output Data, you must also select the corresponding input data samples. This operation makes the number of I/O data samples equal.

  1. In the Control and Estimation Tools Manger GUI, select the New Data node under the Transient Data node.

  2. In the Input Data tab, select the input1(:,1) cell, and click Pre-process.

    This action updates the Data Preprocessing Tool GUI with the selected data input1(:,1).

  3. To exclude the data beyond t = 0.5 s:

    1. In the Exclusion Rules tab, select the Bounds check box.

    2. In the Exclude X field, where X corresponds to the time vector, select > from the drop-down list. Enter 0.5 in the adjacent field to specify the upper limit of the input data to select for estimation.

    3. In the Write results to area, verify that the existing dataset option remains selected.

    4. Click Add.

      This action adds the modified data input1(:,1)* to the Input Data tab of the Dataset1 node. This operation also replaces the input data samples beyond t = 0.5 s in input1(:,1)* with NaNs.

  4. To remove the NaNs:

    1. In the Control and Estimation Tools Manager GUI, select the input1(:,1)* cell in the Input Data tab of the Dataset1 node, and click Pre-process.

      This action updates the Data Preprocessing Tool GUI with the selected data input1(:,1)*.

    2. In the Missing Data Handling area, select the Remove rows where data is excluded or missing check box.

    3. In the Write results to area, verify that the existing dataset option remains selected.

    4. Click Add.

      The Update table data dialog box appears. Click Yes to overwrite the input1(:,1)* data set with the modified data.

  5. To plot the data, select the input1(:,1)* cell in the Input Data tab of the Dataset1 node, and click Plot Data.

    The selected input data from t = 0 s to t = 0.5 s is shown in the next figure.

Removing Outliers

Why Remove Outliers

Outliers are data values that deviate from the mean by more than three standard deviations. When estimating parameters from data containing outliers, the results may not be accurate.

Removing outliers replaces the data samples containing outliers with NaNs, which represent missing data. You interpolate the missing data values in a subsequent operation, as described in Interpolating Missing Data.

How to Remove Outliers

In this portion of the tutorial, you remove outliers from the output data. You must have already selected a subset of the data, as described in Selecting Data for Estimation. If you have not done this preparation, click hereclick here.

  1. In the Control and Estimation Tools Manger, select the position1(:,1)* cell in the Output Data tab of the Dataset1 node, and click Pre-process.

    This action updates the Data Preprocessing Tool GUI with the selected data position1(:,1)*.

  2. In the Exclusion Rules tab, select the Outliers check box.

    By default, the Window length and Confidence limits fields are set to 10 and 95 respectively. The Window length field specifies the number of successive data samples the software uses to compute the mean and standard deviation. The Confidence limits field specifies the threshold number for identifying outliers. In this example, the mean and standard deviation of 10 successive data samples are computed, and data values that exceed 95% of standard deviation are identified as outliers.

      Note:   The data samples containing outliers are replaced with NaNs.

  3. In the Write results to area, verify that the existing dataset option remains selected.

  4. Click Add.

    The Update table data dialog box appears. Click Yes to overwrite the position1(:,1)* data set with the modified data.

  5. To plot the data, select the position1(:,1)* cell in the Output Data tab of the Dataset1 node, and click Plot Data.

    The spikes, which indicate outliers, no longer appear on the time plot, as shown in the next figure.

    The missing data samples, represented by NaNs, appear as gaps on the time plot. To see an example, zoom in to the bottom-left corner of the plot. As shown in the next figure, the data values corresponding to t = 0.009 s and t = 0.019 s are missing.

Filtering Data

Filtering Output Data

In this portion of the tutorial, you filter the noise, and remove any periodic trends from the output data. To avoid relative phase shift between the I/O data, you must also apply the same filter to the input data.

You must have already removed outliers from the output data, as described in Removing Outliers. If you have not done this preparation, click hereclick here.

  1. In the Control and Estimation Tools Manager window, select the position1(:,1)* cell in the Output Data tab of the Dataset1 node, and click Pre-process.

    This action updates the Data Preprocessing Tool GUI with the selected data position1(:,1)*.

  2. In the Detrend/Filtering tab:

    1. Select the Filtering check box.

      By default, First order is selected as the filter type. To learn more about the filters, see Filtering Data.

    2. Specify 0.001 in the First order filter with time constant field.

      This field specifies the time constant for the first-order filter.

        Tip   For calculating the time constant, you can visually inspect the time plot to determine the frequency components.

  3. In the Write results to area, verify that the existing dataset option remains selected.

  4. Click Add.

    The Update table data dialog box appears. Click Yes to overwrite the position1(:,1)* data set with the modified data.

  5. To plot the data, select the position1(:,1)* cell in the Output Data tab of the Dataset1 node, and click Plot Data.

    The noise is filtered and the output data appears smooth, as shown in the next figure.

Filtering Input Data

After you filter the output data, as described in Filtering Output Data, you must also filter the input data with the same filter.

  1. In the Control and Estimation Tools Manager window, select the input1(:,1)* cell in the Input Data tab of the Dataset1 node, and click Pre-process.

    This action updates the Data Preprocessing Tool GUI with the selected data input1(:,1)*.

  2. In the Detrend/Filtering tab:

    1. Select the Filtering check box.

      By default, First order is selected as the filter type.

    2. Specify 0.001 in the First order filter with time constant field.

  3. In the Write results to area, verify that the existing dataset option remains selected.

  4. Click Add.

    The Update table data dialog box appears. Click Yes to overwrite the input1(:,1)* data set with the modified data.

  5. To plot the data, select the input1(:,1)* cell in the Input Data tab of the Dataset1 node, and click Plot Data.

Interpolating Missing Data

In this portion of the tutorial, you interpolate the output data to compute the missing values created when removing outliers, as described in Removing Outliers. The interpolation operation uses the known data values to compute the missing data values.

You must have already filtered the noise, as described in Filtering Data. If you have not already done this preparation, click hereclick here.

  1. In the Control and Estimation Tools Manager GUI, select the position1(:,1)* cell in the Output Data tab of the Dataset1 node, and click Pre-process.

    This action updates the Data Preprocessing Tool GUI with the selected data position1(:,1)*.

  2. In the Missing Data Handling area, select the Interpolate missing values using interpolation method check box.

    By default, zoh is selected as the interpolation method. This method fills the missing data sample with the data value immediately preceding it.

      Tip   You can view the interpolated data samples in the Modified data tab.

  3. In the Write results to area, verify that the existing dataset option remains selected.

  4. Click Add.

    The Update table data dialog box appears. Click Yes to overwrite the position1(:,1)* data set with the modified data.

  5. To plot the data, select the position1(:,1)* cell in the Output Data tab of the Dataset1 node, and click Plot Data.

    The new estimation data, prepared by removing outliers, filtering noise, and interpolating missing data, is shown the next figure.

Saving the Project

After you prepare the data, you can delete the data in the New Data node, rename the prepared data, and save the session. To skip the data preparation steps, click hereclick here.

  1. In the Control and Estimation Tools Manger GUI, select the New Data node under the Transient Data node.

  2. Right-click the New Data node, and select Delete.

  3. Select the Dataset1 node under the Transient Data node.

  4. Right-click the Dataset1 node, and select Rename. Specify Estim_Data_Prep as the name of the new estimation data set.

    The Control and Estimation Tools Manager GUI resembles the next figure.

  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 spe_engine_throttle1p.mat in the File name field, and click Save.

      The action saves the project as a MAT-file.

To learn how to estimate parameters from this data, see Estimate Parameters from Measured Data (GUI).

Was this topic helpful?