Products & Services Solutions Academia Support User Community Company

Learn more about System Identification Toolbox   

Filtering Data

Supported Filters

You can filter the input and output signals through a linear filter before estimating a model in the System Identification Tool GUI or at the command line. How you want to handle the noise in the system determines whether it is appropriate to prefilter the data.

The filter available in the System Identification Tool GUI is a fifth-order (passband) Butterworth filter. If you need to specify a custom filter, use the idfilt command.

Choosing to Prefilter Your Data

Prefiltering data can help remove high-frequency noise or low-frequency disturbances (drift). The latter application is an alternative to subtracting linear trends from the data, as described in Handling Offsets and Trends in Data.

In addition to minimizing noise, prefiltering lets you focus your model on specific frequency bands. The frequency range of interest often corresponds to a passband over the breakpoints on a Bode plot. For example, if you are modeling a plant for control-design applications, you might prefilter the data to specifically enhance frequencies around the desired closed-loop bandwidth.

Prefiltering the input and output data through the same filter does not change the input-output relationship for a linear system. However, prefiltering does change the noise characteristics and affects the estimated model of the system.

To get a reliable noise model, avoid prefiltering the data. Instead, set the Focus property of the estimation algorithm to Simulation. For more information about the Focus property, see the Algorithm Properties reference page.

How to Filter Data Using the GUI

Filtering Time-Domain Data in the GUI

The System Identification Tool GUI lets you filter time-domain data using a fifth-order Butterworth filter by enhancing or selecting specific passbands.

To create a filtered data set:

  1. Import time-domain data into the System Identification Tool GUI, as described in Importing Data into the GUI.

  2. Drag the data set you want you want to filter to the Working Data area.

  3. Select <--Preprocess > Filter. By default, this selection shows a periodogram of the input and output spectra (see the etfe reference page).

      Note   To display smoothed spectral estimates instead of the periodogram, select Options > Spectral analysis. This spectral estimate is computed using spa and your previous settings in the Spectral Model dialog box. To change these settings, select <--Estimate > Spectral model in the System Identification Tool GUI, and specify new model settings.

  4. If your data contains multiple input/output channels, in the Channel menu, select the channel pair you want to view. Although you view only one channel pair at a time, the filter applies to all input/output channels in this data set.

  5. Select the data of interest using one of the following ways:

    • Graphically — Draw a rectangle with the mouse on either the input-signal or the output-signal plot to select the desired frequency interval. Your selection is displayed on both plots regardless of the plot on which you draw the rectangle. The Range field is updated to match the selected region. If you need to clear your selection, right-click the plot.

    • Specify the Range — Edit the beginning and the end frequency values.

      For example:

      8.5 20.0 (rad/s).

        Tip   To change the frequency units from rad/s to Hz, select Style > Frequency (Hz). To change the frequency units from Hz to rad/s, select Style > Frequency (rad/s).

  6. In the Range is list, select one of the following:

    • Pass band — Allows data in the selected frequency range.

    • Stop band — Excludes data in the selected frequency range.

  7. Click Filter to preview the filtered results. If you are satisfied, go to step 8. Otherwise, return to step 5.

  8. In the Data name field, enter the name of the data set containing the selected data.

  9. Click Insert to save the selection as a new data set and add it to the Data Board.

  10. To select another range, repeat steps 5 to 9.

Filtering Frequency-Domain or Frequency-Response Data in the GUI

For frequency-domain and frequency-response data, filtering is equivalent to selecting specific data ranges.

To select a range of data in frequency-domain or frequency-response data:

  1. Import data into the System Identification Tool GUI, as described in Importing Data into the GUI.

  2. Drag the data set you want you want to filter to the Working Data area.

  3. Select <--Preprocess > Select range. This selection displays one of the following plots:

    • Frequency-domain data — Plot shows the absolute of the squares of the input and output spectra.

    • Frequency-response data — Top axes show the frequency response magnitude equivalent to the ratio of the output to the input, and the bottom axes show the ratio of the input signal to itself, which has the value of 1 at all frequencies.

  4. If your data contains multiple input/output channels, in the Channel menu, select the channel pair you want to view. Although you view only one channel pair at a time, the filter applies to all input/output channels in this data set.

  5. Select the data of interest using one of the following ways:

    • Graphically — Draw a rectangle with the mouse on either the input-signal or the output-signal plot to select the desired frequency interval. Your selection is displayed on both plots regardless of the plot on which you draw the rectangle. The Range field is updated to match the selected region.

      If you need to clear your selection, right-click the plot.

    • Specify the Range — Edit the beginning and the end frequency values.

      For example:

      8.5 20.0 (rad/s).

        Tip   If you need to change the frequency units from rad/s to Hz, select Style > Frequency (Hz). To change the frequency units from Hz to rad/s, select Style > Frequency (rad/s).

  6. In the Range is list, select one of the following:

    • Pass band — Allows data in the selected frequency range.

    • Stop band — Excludes data in the selected frequency range.

  7. In the Data name field, enter the name of the data set containing the selected data.

  8. Click Insert. This action saves the selection as a new data set and adds it to the Data Board.

  9. To select another range, repeat steps 5 to 8.

How to Filter Data at the Command Line

Simple Passband Filter

Use idfilt to apply passband and other custom filters to a time-domain or a frequency-domain iddata object.

In general, you can specify any custom filter. Use this syntax to filter an iddata object data using the filter called filter:

fdata = idfilt(data,filter)

In the simplest case, you can specify a passband filter for time-domain data using the following syntax:

fdata = idfilt(data,[wl wh])

In this case, w1 and wh represent the low and high frequencies of the passband, respectively.

You can specify several passbands, as follows:

filter=[[w1l,w1h];[ w2l,w2h]; ....;[wnl,wnh]]

The filter is an n-by-2 matrix, where each row defines a passband in radians per second.

To define a stopband between ws1 and ws2, use

filter = [0 ws1; ws2 Nyqf]

where, Nyqf is the Nyquist frequency.

For time-domain data, the passband filtering is cascaded Butterworth filters of specified order. The default filter order is 5. The Butterworth filter is the same as butter in the Signal Processing Toolbox product. For frequency-domain data, select the indicated portions of the data to perform passband filtering.

Defining a Custom Filter

Use idfilt to apply passband and other custom filters to a time-domain or a frequency-domain iddata object.

In general, you can specify any custom filter. Use this syntax to filter an iddata object data using the filter called filter:

fdata = idfilt(data,filter)

You can define a general single-input/single-output (SISO) system for filtering time-domain or frequency-domain data. For frequency-domain only, you can specify the (nonparametric) frequency response of the filter.

You use this syntax to filter an iddata object data using a custom filter specified by filter:

fdata = idfilt(data,filter)

filter can be also any of the following:

filter = idm
filter = {num,den}
filter = {A,B,C,D}

idm is a SISO idmodel or LTI object. For more information about LTI objects, see the Control System Toolbox documentation.

{num,den} defines the filter as a transfer function as a cell array of numerator and denominator filter coefficients.

{A,B,C,D} is a cell array of SISO state-space matrices.

Specifically for frequency-domain data, you specify the frequency response of the filter:

filter = Wf

Here, Wf is a vector of real or complex values that define the filter frequency response, where the inputs and outputs of data at frequency data.Frequency(kf) are multiplied by Wf(kf). Wf is a column vector with the length equal to the number of frequencies in data.

When data contains several experiments, Wf is a cell array with the length equal to the number of experiments in data.

Causal and Noncausal Filters

For time-domain data, the filtering is causal by default. Causal filters typically introduce a phase shift in the results. To use a noncausal zero-phase filter (corresponding to filtfilt in the Signal Processing Toolbox product), specify a third argument in idfilt:

fdata = idfilt(data,filter,'noncausal')

For frequency-domain data, the signals are multiplied by the frequency response of the filter. With the filters defined as passband filters, this calculation gives ideal, zero-phase filtering ("brick wall filters"). Frequencies that have been assigned zero weight by the filter (outside the passband or via frequency response) are removed.

When you apply idfilt to an idfrd data object, the data is first converted to a frequency-domain iddata object (see Transforming Between Frequency-Domain and Frequency-Response Data). The result is an iddata object.

See Also

To learn how to filter data during linear model estimation instead, you can set the Focus property of the estimation algorithm to Filter and specify the filter characteristics. For more information about model properties, see the Algorithm Properties reference page.

For more information about prefiltering data, see the chapter on preprocessing data in System Identification: Theory for the User, Second Edition, by Lennart Ljung, Prentice Hall PTR, 1999.

For practical examples of prefiltering data, see the section on posttreatment of data in Modeling of Dynamic Systems, by Lennart Ljung and Torkel Glad, Prentice Hall PTR, 1994.

  


Recommended Products

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.

 © 1984-2009- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS