Wavelet Toolbox | ![]() ![]() |
One-Dimensional Analysis Using the Command Line
This example involves a noisy Doppler test signal.
Let us mention that for the SWT, if a decomposition at level k
is needed, 2^k
must divide evenly into the length of the signal. If your original signal does not have the correct length, you can use the Signal Extension GUI tool or the wextend
function to extend it.
Performing a Single-Level Stationary Wavelet Decomposition of a Signal..
db1
wavelet. Type:
[swa,swd] = swt(s,1,'db1');
This generates the coefficients of the level 1 approximation (swa) and detail (swd). Both are of the same length as the signal. Type:
whos
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
swa |
|
|
|
swd |
|
|
|
Displaying the Coefficients of Approximation and Detail..
subplot(1,2,1), plot(swa); title('Approximation cfs') subplot(1,2,2), plot(swd); title('Detail cfs')
Regenerating a Signal by Inverse Stationary Wavelet Transform. .
To check the perfect reconstruction, type:
err = norm(s-A0) err = 2.1450e-14
Constructing Approximation and Detail from the Coefficients..
A1
and D1
) from the coefficients swa
and swd
, type:
nulcfs = zeros(size(swa)); A1 = iswt(swa,nulcfs,'db1'); D1 = iswt(nulcfs,swd,'db1');
Displaying the Approximation and Detail..
subplot(1,2,1), plot(A1); title('Approximation A1'); subplot(1,2,2), plot(D1); title('Detail D1');
Performing a Multilevel Stationary Wavelet Decomposition of a Signal. .
db1
wavelet), type:
[swa,swd] = swt(s,3,'db1');
This generates the coefficients of the approximations at levels 1, 2, and 3
(swa
) and the coefficients of the details (swd
). Observe that the rows of swa
and swd
are the same length as the signal length. Type:
clear A0 A1 D1 err nulcfs whos
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
swa |
|
|
|
swd |
|
|
|
Displaying the Coefficients of Approximations and Details. .
kp = 0; for i = 1:3 subplot(3,2,kp+1), plot(swa(i,:)); title(['Approx. cfs level ',num2str(i)]) subplot(3,2,kp+2), plot(swd(i,:)); title(['Detail cfs level ',num2str(i)]) kp = kp + 2; end
Reconstructing Approximation at Level 3 From Coefficients..
mzero = zeros(size(swd)); A = mzero; A(3,:) = iswt(swa,mzero,'db1');
Reconstructing Details From Coefficients..
D = mzero; for i = 1:3 swcfs = mzero; swcfs(i,:) = swd(i,:); D(i,:) = iswt(mzero,swcfs,'db1'); end
Reconstructing Approximations at Levels 1 and 2 from Approximation at Level 3 and Details at Levels 2 and 3..
A(2,:) = A(3,:) + D(3,:); A(1,:) = A(2,:) + D(2,:);
Displaying the Approximations and Details..
kp = 0; for i = 1:3 subplot(3,2,kp+1), plot(A(i,:)); title(['Approx. level ',num2str(i)]) subplot(3,2,kp+2), plot(D(i,:)); title(['Detail level ',num2str(i)]) kp = kp + 2; end
Removing Noise by Thresholding..
ddencmp
command to calculate a default global threshold. Use the wthresh
command to perform the actual thresholding of the detail coefficients, and then use the iswt
command to obtain the de-noised signal.
[thr,sorh] = ddencmp('den','wv',s); dswd = wthresh(swd,sorh,thr); clean = iswt(swa,dswd,'db1');
subplot(2,1,1), plot(s); title('Original signal') subplot(2,1,2), plot(clean); title('De-noised signal')
s
at level 5 instead of level 3, and repeating steps 14 and 15. To improve the previous de-noising, type:
[swa,swd] = swt(s,5,'db1'); [thr,sorh] = ddencmp('den','wv',s); dswd = wthresh(swd,sorh,thr); clean = iswt(swa,dswd,'db1'); subplot(2,1,1), plot(s); title('Original signal') subplot(2,1,2), plot(clean); title('De-noised signal')
swt
and iswt
functions, giving the same results:
lev = 5; swc = swt(s,lev,'db1'); swcden = swc; swcden(1:end-1,:) = wthresh(swcden(1:end-1,:),sorh,thr); clean = iswt(swcden,'db1');
You can obtain the same plot by using the same plot commands than in step 16 above.
![]() | One-Dimensional Discrete Stationary Wavelet Analysis | One-Dimensional Analysis for De-noising Using the Graphical Interface | ![]() |