% Course in Wavelets, TU Chemnitz, 2012
% 
% uses function y=cascade(x,l,h,options)
% Computes the scaling function or wavelet by the cascade algorithm.
%
% x       evaluation points
% l       recursion depth
% h       scaling filter
%
% options 'phi' scaling function 
%         'psi' wavelet
%

%a=13*pi/12;
%h=sqrt(2)/4+[cos(a),sin(a),-cos(a),-sin(a)]/2
h=1/sqrt(2)/4*[1+sqrt(3),3+sqrt(3),3-sqrt(3),1-sqrt(3)]

x=-1:0.01:3;
l=2;
phi2=cascade(x,l,h,'phi');
psi2=cascade(x,l,h,'psi');

l=6;
phi4=cascade(x,l,h,'phi');
psi4=cascade(x,l,h,'psi');

subplot(2,2,1);
plot(x,phi2);
subplot(2,2,2);
plot(x,psi2);
subplot(2,2,3);
plot(x,phi4);
subplot(2,2,4);
plot(x,psi4);
