%**********************************************************
%**               Diskretni transformace                 **
%**               generování Haarove baze                **
%** Leos Marsalek (c) 2002-2003 Leos.Marsalek@tiscali.cz **
%**********************************************************
function [baze]=haar(n);     % n udává velikost bázove matice
N=2^n;
z=1/N;
s=1;
har=zeros(N,N);
har(1,:)=1;
for m=0:n-1
    
for k=0:N   
        
for r=1:N
            x=z*(r)-0.1/N;
            
if (2*k-2)/2^(m+1)<x
                
if x<(2*k-1)/2^(m+1)
                har(2^m+k,r)=sqrt(2^m);
                
end
            end
            if 
(2*k-1)/2^(m+1)<x
                
if x<(2*k)/2^(m+1)
                har(2^m+k,r)=-sqrt(2^m);
                
end
            end
        end
    end
end
baze=har;