% To show that the frequencies stay local in DWT

% the signal has 2 frequencies

x = (1:2048)/100;
y = sin(x);
y(1:628) = sin(50*x(1:628));

figure(1), subplot(2,2,1),plot(x,y)                    
title('The signal'), axis([5,12,-1,1]), axis off
% print -deps localtime.eps

% compute DWT

qmf = ortfilt('Coiflet',3);
[h, g, ht, gt, sh, sg, sht, sgt] = qmf2hgs(qmf);
w = zeros(2048,1);  
w(13) = 1;          
psi = IWT_BIO(w,0,h,g,sh,sg);
%figure(2),
subplot(2,2,2), plot(psi)
axis([1 2048 -0.1 0.1])
title('The wavelet function used')

% The DWT

w = FWT_BIO(y,0,ht,gt,sht,sgt);
%figure(3),
subplot(2,2,3), plotscales(w,7,-20,20)
title('The wavelet transform')
% print -deps localfreqtime.eps

% The Fourier transform

Y = DTFTfast(y,length(y));
%figure(4),
subplot(2,2,4), plot((0:4096)*pi/2048-pi,abs(Y))
axis([-pi pi 0 800])
title('The Fourier transform')
% print -deps localfreq.eps


