Wavelet Toolbox Previous page   Next Page

One-Dimensional Analysis Using the Command Line

This example involves a real-world signal -- electrical consumption measured over the course of 3 days. This signal is particularly interesting because of noise introduced when a defect developed in the monitoring equipment as the measurements were being made. Wavelet analysis effectively removes the noise.

  1. Load a signal.
  1. From the MATLAB prompt, type

    Set the variables. Type

  1. Perform a single-level wavelet decomposition of a signal.
  1. Perform a single-level decomposition of the signal using the db1 wavelet. Type

    This generates the coefficients of the level 1 approximation (cA1) and detail (cD1).

  1. Construct approximations and details from the coefficients.
  1. To construct the level 1 approximation and detail (A1 and D1) from the coefficients cA1 and cD1, type

    or

  1. Display the approximation and detail.
  1. To display the results of the level-one decomposition, type

  1. Regenerate a signal by using the Inverse Wavelet Transform.
  1. To find the inverse transform, type

  1. Perform a multilevel wavelet decomposition of a signal.
  1. To perform a level 3 decomposition of the signal (again using the db1 wavelet), type

    The coefficients of all the components of a third-level decomposition (that is, the third-level approximation and the first three levels of detail) are returned concatenated into one vector, C. Vector L gives the lengths of each component.

  1. Extract approximation and detail coefficients.
  1. To extract the level 3 approximation coefficients from C, type

    To extract the levels 3, 2, and 1 detail coefficients from C, type

    or

    Results are displayed in the figure below, which contains the signal s, the approximation coefficients at level 3 (cA3), and the details coefficients from level 3 to 1 (cD3, cD2 and cD1) from the top to the bottom.

  1. Reconstruct the Level 3 approximation and the Level 1, 2, and 3 details.
  1. To reconstruct the level 3 approximation from C, type

    To reconstruct the details at levels 1, 2, and 3, from C, type

  1. Display the results of a multilevel decomposition.
  1. To display the results of the level 3 decomposition, type

  1. Reconstruct the original signal from the Level 3 decomposition
  1. To reconstruct the original signal from the wavelet decomposition structure, type

  1. Crude de-noising of a signal.
  1. Using wavelets to remove noise from a signal requires identifying which component or components contain the noise, and then reconstructing the signal without those components.

    In this example, we note that successive approximations become less and less noisy as more and more high-frequency information is filtered out of the signal.

    The level 3 approximation, A3, is quite clean as a comparison between it and the original signal.

    To compare the approximation to the original signal, type

    Of course, in discarding all the high-frequency information, we've also lost many of the original signal's sharpest features.

    Optimal de-noising requires a more subtle approach called thresholding. This involves discarding only the portion of the details that exceeds a certain limit.

  1. Remove noise by thresholding.
  1. Let's look again at the details of our level 3 analysis.

    To display the details D1, D2, and D3, type

    Most of the noise occurs in the latter part of the signal, where the details show their greatest activity. What if we limited the strength of the details by restricting their maximum values? This would have the effect of cutting back the noise while leaving the details unaffected through most of their durations. But there's a better way.

    Note that cD1, cD2, and cD3 are just MATLAB vectors, so we could directly manipulate each vector, setting each element to some fraction of the vectors' peak or average value. Then we could reconstruct new detail signals D1, D2, and D3 from the thresholded coefficients.

    To de-noise the signal, use the ddencmp command to calculate the default parameters and the wdencmp command to perform the actual de-noising, type

    Note that wdencmp uses the results of the decomposition (C and L) that we calculated in Step 6. We also specify that we used the db1 wavelet to perform the original analysis, and we specify the global thresholding option 'gbl'. See ddencmp and wdencmp in the reference pages for more information about the use of these commands.

    To display both the original and de-noised signals, type

    We've plotted here only the noisy latter part of the signal. Notice how we've removed the noise without compromising the sharp detail of the original signal. This is a strength of wavelet analysis.

    While using command line functions to remove the noise from a signal can be cumbersome, the Wavelet Toolbox graphical interface tools include an easy-to-use de-noising feature that includes automatic thresholding.

    More information on the de-noising process can be found in the following sections:


Previous page  One-Dimensional Discrete Wavelet Analysis One-Dimensional Analysis Using the Graphical Interface Next page

© 1994-2005 The MathWorks, Inc.