Wavelet Toolbox |
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.
db1
wavelet. Type
This generates the coefficients of the level 1 approximation (cA1
) and detail (cD1
).
A1
and D1
) from the coefficients cA1
and cD1
, 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.
To extract the levels 3, 2, and 1 detail coefficients from C, type
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.
To reconstruct the details at levels 1, 2, and 3, from C, type
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
subplot(2,1,1);plot(s);title('Original'); axis off subplot(2,1,2);plot(A3);title('Level 3 Approximation'); axis off
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.
To display the details D1
, D2
, and D3
, type
subplot(3,1,1); plot(D1); title('Detail Level 1'); axis off subplot(3,1,2); plot(D2); title('Detail Level 2'); axis off subplot(3,1,3); plot(D3); title('Detail Level 3'); axis off
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
subplot(2,1,1); plot(s(2000:3920)); title('Original') subplot(2,1,2); plot(clean(2000:3920)); title('De-noised')
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:
One-Dimensional Discrete Wavelet Analysis | One-Dimensional Analysis Using the Graphical Interface |
© 1994-2005 The MathWorks, Inc.