%例程6-8 方波信号的离散小波变换
% e.g.6-8.m for example6-8;
%test the function of dwt
clear all;
t=0:.01*pi:10*pi;
x=square(t,80);
X=x+randn(size(x))/10;
subplot(311); plot(t,X);
xlabel('Time t');
axis([0 11*pi -2 2]);
ylabel('Amplitude X');
title('Analyzed signal ')
% Perform single-level discrete wavelet transform of X by haar
%and the kind of signal extension mode is zero-padding extension.
[ca1,cd1] = dwt(X,'haar','mode','zpd');
subplot(323); plot(ca1); title('Approx. coef. for haar');
subplot(324); plot(cd1); title('Detail coef. for haar');
% Perform single-level discrete wavelet transform of X by coif4,use the default mode .
% and observe edge effects for last coefficients.
[ca2,cd2] = dwt(X,'coif4','mode','sym');
subplot(325); plot(ca2); title('Approx. coef. for coif4');
subplot(326); plot(cd2); title('Detail coef. for coif4');