%vstupne parametre
% Haarov wavelet 
%    a=0; b=0
% Db2 wavelet
    a=3.1415926/3; b=0
% Db3 wavelet
%    a=1.35980; b=-0.7821

iterations=8
initsignal=[0 1 0]


%filtre vypocitame parametrizovanymi vzorcami
if a==b,  h = [1,1]/sqrt(2);            % Length-2
elseif b==0
   h0 = (1 - cos(a) + sin(a))/2;        % Length-4
   h1 = (1 + cos(a) + sin(a))/2;
   h2 = (1 + cos(a) - sin(a))/2;
   h3 = (1 - cos(a) - sin(a))/2;
   h  = [h0 h1 h2 h3]/sqrt(2);
else                                    % Length-6
   h0 = ((1+cos(a)+sin(a))*(1-cos(b)-sin(b))+2*sin(b)*cos(a))/4;
   h1 = ((1-cos(a)+sin(a))*(1+cos(b)-sin(b))-2*sin(b)*cos(a))/4;
   h2 = (1+cos(a-b)+sin(a-b))/2;
   h3 = (1+cos(a-b)-sin(a-b))/2;
   h4 = (1-h0-h2);
   h5 = (1-h1-h3);
   h = [h0 h1 h2 h3 h4 h5]/sqrt(2);
end

%zobrazime vysledne filtre
h
g=qmf(h)

%zobrazime vysledne phi(t) a psi (t)
for a=1:iterations
   phi=upcoef('a',initsignal,h,g,a);
   psi=upcoef('d',initsignal,h,g,a);
   subplot(2,1,1)
   plot(phi)
   subplot(2,1,2)
   plot(psi);
 pause
end