% show 1-level  and 2-level dwt on a 1-d signal 
% circular convolution is used
% wavelet toolbox is not used
N = 1024;
t = (0:(N-1))/N;
X = 2*sin(2*pi*5*t)+0.7*cos(2*pi*24*t)+ 0.5*sin(2*pi*60*t);
figure(1)
plot(t,X);
title('original signal')

g =  [1,1]/2;
h =  [1 -1]/2;

figure(2)
Xl = circconv(X,g); Xl = Xl(1:2:(N-1));
Xh = circconv(X,h); Xh = Xh(1:2:(N-1));
plot([Xl,Xh]);
title('one-level DWT')


figure(3)

Xll = circconv(Xl,g); Xll = Xll(1:2:(N/2-1));
Xlh = circconv(Xl,h); Xlh = Xlh(1:2:(N/2-1));
plot([Xll,Xlh,Xh]);
title('two-level DWT')



