Main Content

Prepare Data for Parameter Estimation

About This Tutorial

Objectives

This tutorial explains 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.

执行以下任务使用Parameter Estimator:

  • Import data from the MATLAB®workspace.

  • Analyze data quality using a time plot.

  • Select a subset of data for estimation.

  • Replace outliers.

  • Filter high-frequency noise.

About the Sample Data

Loadspe_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_throttle1contains the Simulink model of the engine throttle system.

Start aParameter EstimatorSession

To perform parameter estimation, you must first start aParameter Estimatorsession.

  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.

  2. In the Simulink model window, on theAppstab, underControl Systems, selectParameter Estimator.

    该操作将会打开一个新的会话,参数估计- spe_engine_throttle1, in theParameter Estimator.

    Note

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

Create an Experiment for Parameter Estimation

In theParameter Estimatoron theParameter Estimationtab, click theNew Experimentbutton. This will create an experiment with the nameExpin theExperimentslist on the left pane. You can rename it by right-clicking and selectingRenamefrom the list. For example, call itNewData1.

Import Data

This portion of the tutorial explains how to import measured I/O data into the experiment in theParameter Estimator. Importing data assigns the data to the corresponding model input and output signals.

The model input and output signals are designated with the InportInputand OutportPositionblocks, respectively. To learn more about the blocks, see theInportandOutportblock reference pages in the Simulink documentation.

To import data into the experiment, right-click and selectEdit...to launch the experiment editor. Import the output data by typing[time1, position1]in the dialog box in theOutputspanel. Import the input data by typing[time1,input1]in the dialog box in theInputspanel.

Analyze Data

This portion of the tutorial explains how to analyze the output data quality by viewing the data characteristics on a time plot. Based on the analysis, you can 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.

To create an experiment plot, clickAdd Ploton theParameter Estimationtab and select the experiment name, for example,NewData1underExperiment Plots.

The time plot shows the output data in response to a step input, as described inAbout 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, select the data samples between t = 0 s and t = 0.5 s, as inExtract Data for Estimation.

的峰值data indicateoutliers, defined as data values that deviate from the mean by more than three standard deviations. They might be caused by measurement errors or sensor problems. The response also contains noise. Before estimating model parameters from this data, remove the outliers and filter the noise, as described inReplacing OutliersandFiltering Data.

You can also plot the experiment data by right-clicking the experiment, for exampleNewData1, and selectingPlot measured experiment datafrom the list.

Extract Data for Estimation

This portion of the tutorial explains how to select a subset of I/O data for estimation. As described inAnalyze Data, the system is shut down at t = 0.5 s. To focus the estimation on the time period before t = 0.5 s, 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.

First, import the data into the experiment, as described inImport Data.

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

  1. Plot the measured data as described inAnalyze Data, to have access to theExperiment Plottab.

  2. On theExperiment Plottab, clickExtract Datato launch theExtract Datatab.

  3. Enter 0 in theStart Time:field and 0.5 in theEnd Time:field.

  4. ClickSave Asto save data in a new experiment, for example,NewData1_1.

TheParameter Estimatorextracts the corresponding input data. To plot the new data, click onAdd Ploton theParameter Estimationtab. Select the experiment name, for example,NewData1_1in theExperiment Plots列表来维isplay the experiment plot of the data from t = 0 s to t = 0.5 s.

Replacing Outliers

Why Replace 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 might not be accurate. Hence, you might choose to replace the outliers in the data before you estimate the parameters.

How to Replace Outliers

In the experiment plot of the data extracted as inExtract Data for Estimation, you can visually detect the data points that seem to be outliers. To replace these points:

  1. In theExperiment Plottab, clickReplace datato launch theReplace datatab. The experiment plot shows the preview data, which is in light brown. On the preview, select the data point that you want to replace.

  2. On theReplace Datatab, clickReplace dataand select the constant value. For example, replace the output signal data that correspond to time points 0.00899 and 0.0189 with 15, that corresponds to the time point 0.149 with 86, and the rest of the outlier data points with 90.

  3. Click the arrow in theApplysection and selectSave As: Create a new experiment from the modified data.Parameter Estimatorsaves the modified data in the new experiment, for example,NewData1_1_1.

  4. ClickAdd Ploton theParameter Estimationtab and select the new experiment, for example,NewData1_1_1. This creates an experiment plot of the modified data. The spikes, that indicated outliers, no longer appear on the time plot.

Filtering Data

This portion of the tutorial explains how to filter the noise and remove any periodic trends from the output data. First remove the outliers from the output data, as described inReplacing Outliers.

Click the experiment plot for the new experiment, for example,NewData1_1_1. On theExperiment Plottab, clickLow-Pass Filter.

  1. On theLow-Pass Filtertab selectFilter all signals.

  2. Enter 0.4 in theNormalized cutoff frequencyfield.

  3. ClickOptions. Enter 1 in theFilter orderfield and clickOK.

  4. Click the arrow in theApplysection and selectSave As: Create a new experiment from the modified data.Parameter Estimatorsaves the modified data in the new experiment, for example,NewData1_1_1_1.

  5. ClickAdd Ploton theParameter Estimationtab and select the new experiment,NewData1_1_1_1. This creates an experiment plot of the modified data. The noise is filtered and the output data appears smooth.

Saving the Session

After you prepare the data, delete the data in the older experiments, for example,New Data1,New Data1_1,New Data1_1_1. You can rename the last experiment, for example,NewData1_1_1_1asNewData1, and save the session.

To delete the experiments, right-click the experiment name in theExperimentspane, and select删除from the list.

To save the session, clickSave Sessionon theParameter Estimationtab to select where to save the session. Specify a name for the session, for example,spe_engine_throttle1_sdosession.matin theFile nameorSessionfield, and then clickSaveorOK. This saves your parameter estimation session as a MAT-file.

To learn how to estimate parameters from this data, seeEstimate Parameters from Measured Data.