function [Tmatica88, koeficienty88, Tmatica44, koeficienty44, Tmatica22, keoficienty22]=dwt()
signal=[1; 1; 1; 1; 1; 1;1; 1];
%zadefinovany nas signal
[a b c d]=wfilters('Db10');

hmr=c;
gmr=d;
gmra=gmr;
gmrb=gmr;
%c,d oznacim ako v nasom priklade
hmr=[c 0 0 0 0 0 0];
gmr=[d 0 0 0 0 0 0];
gmra=gmr;
gmrb=gmr;
hmra=hmr;
hmrb=hmr;

nuly=mod(length(hmr),8);

if nuly>0;
    dlzka=8-nuly;
    hmr=[hmr zeros(1, dlzka)];
    hmra=hmr;
    hmrb=hmr;
end
%definicia matice aby bola na zaciatku nulova
matica=[0 0 0 0 0 0 0 0];
m=1;
n=8;
    while n<=length(hmr);
        maticaa=hmr(m:n);
        matica=matica+maticaa;
        if (n+8)==length(hmr);
            n=length(hmr);
        else (n+8)<length(hmr);
            n=n+8;
        end
        m=m+8;
    end
hmr1=matica;
%druhy riadok
hmr=circshift(hmr, [0 2]);
%posun o dva prvky doprava
matica=[0 0 0 0 0 0 0 0];
m=1;
n=8;
    while n<=length(hmr);
        maticaa=hmr(m:n);
        matica=matica+maticaa;
        if (n+8)==length(hmr);
            n=length(hmr);
        else (n+8)<length(hmr) ;
            n=n+8;
        end
        m=m+8;
    end
hmr2=matica;
%priradenie vypocitaneho riadku do prveho riadku matice hmr
%treti riadok
hmr=circshift(hmr, [0 2]);
matica=[0 0 0 0 0 0 0 0];
m=1;
n=8;
    while n<=length(hmr);
        maticaa=hmr(m:n);
        matica=matica+maticaa;
        if (n+8)==length(hmr);
            n=length(hmr);
        else (n+8)<length(hmr);
            n=n+8;
        end
        m=m+8;
    end
hmr3=matica;
%stvrty riadok
hmr=circshift(hmr, [0 2]);
matica=[0 0 0 0 0 0 0 0];
m=1;
n=8;
    while n<=length(hmr);
        maticaa=hmr(m:n);
        matica=matica+maticaa;
        if (n+8)==length(hmr);
            n=length(hmr);
        else (n+8)<length(hmr); 
            n=n+8;
        end
        m=m+8;
    end
hmr4=matica;
hmr=[hmr1; hmr2; hmr3; hmr4];
%cyklus na scitavanie precnievajucich prvkov pre 1 riadok matice zvysne
%riadky su rovnake iba to robime s hmr orotovanym o 2


nuly=mod(length(gmr),8);
%zistujem aka dlha je matica hmr a ci je delitelna 8 ako nie pridame tolko
%nul do matice aby bola celociselne delitelna 8
if nuly>0;
    dlzka=8-nuly;
    gmr=[gmr zeros(1, dlzka)];
    gmra=gmr;
    gmrb=gmr;
end
%definicia matice aby bola na zaciatku nulova
matica=[0 0 0 0 0 0 0 0];
m=1;
n=8;
    while n<=length(gmr);
        maticaa=gmr(m:n);
        matica=matica+maticaa;
        if (n+8)==length(gmr);
            n=length(gmr);
        else (n+8)<length(gmr);
            n=n+8;
        end
        m=m+8;
    end
gmr1=matica;
%druhy riadok
gmr=circshift(gmr, [0 2]);
%posun o dva prvky doprava
matica=[0 0 0 0 0 0 0 0];
m=1;
n=8;
    while n<=length(gmr);
        maticaa=gmr(m:n);
        matica=matica+maticaa;
        if (n+8)==length(gmr);
            n=length(gmr);
        else (n+8)<length(gmr);
            n=n+8;
        end
        m=m+8;
    end
gmr2=matica;
%priradenie vypocitaneho riadku do prveho riadku matice hmr
%treti riadok
gmr=circshift(gmr, [0 2]);
matica=[0 0 0 0 0 0 0 0];
m=1;
n=8;
    while n<=length(gmr);
        maticaa=gmr(m:n);
        matica=matica+maticaa;
        if (n+8)==length(gmr);
            n=length(gmr);
        else (n+8)<length(gmr); 
            n=n+8;
        end
        m=m+8;
    end
gmr3=matica;
%stvrty riadok
gmr=circshift(gmr, [0 2]);
matica=[0 0 0 0 0 0 0 0];
m=1;
n=8;
    while n<=length(gmr);
        maticaa=gmr(m:n);
        matica=matica+maticaa;
        if (n+8)==length(gmr);
            n=length(gmr);
        else (n+8)<length(gmr); 
            n=n+8;
        end
        m=m+8;
    end
gmr4=matica;
gmr=[gmr1; gmr2; gmr3; gmr4];

Tmatica88=[hmr; gmr];
koeficienty88=Tmatica88*signal;

%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
%vypocet koeficientov pre 4x4
matica=[0 0 0 0];
m=1;
n=4;
    while n<=length(hmra);
        maticaa=hmra(m:n);
        matica=matica+maticaa;
        if (n+4)==length(hmra);
            n=length(hmra);
        else (n+4)<length(hmra); 
            n=n+4;
        end
        m=m+4;
    end
hmr11=matica;
%druhy riadok
hmra=circshift(hmra, [0 2]);
%posun o dva prvky doprava
matica=[0 0 0 0];
m=1;
n=4;
    while n<=length(hmra);
        maticaa=hmra(m:n);
        matica=matica+maticaa;
        if (n+4)==length(hmra);
            n=length(hmra);
        else (n+4)<length(hmra); 
            n=n+4;
        end
        m=m+4;
    end
hmr22=matica;
hmr=[hmr11; hmr22];
%cyklus na scitavanie precnievajucich prvkov pre 1 riadok matice zvysne
%riadky su rovnake iba to robime s hmr orotovanym o 2
%definicia matice aby bola na zaciatku nulova
matica=[0 0 0 0];
m=1;
n=4;
    while n<=length(gmra);
        maticaa=gmra(m:n);
        matica=matica+maticaa;
        if (n+4)==length(gmra);
            n=length(gmra);
        else (n+4)<length(gmra); 
            n=n+4;
        end
        m=m+4;
    end
gmr11=matica;
%druhy riadok
gmra=circshift(gmra, [0 2]);
%posun o dva prvky doprava
matica=[0 0 0 0];
m=1;
n=4;
    while n<=length(gmra);
        maticaa=gmra(m:n);
        matica=matica+maticaa;
        if (n+4)==length(gmra);
            n=length(gmra);
        else (n+4)<length(gmra); 
            n=n+4;
        end
        m=m+4;
    end
gmr22=matica;
gmr=[gmr11; gmr22];

Tmatica44=[hmr; gmr];
koeficienty44=Tmatica44*koeficienty88(1:4, 1);
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
%vypocet koeficientov pre 4x4
matica=[0 0];
m=1;
n=2;
    while n<=length(hmrb);
        maticaa=hmrb(m:n);
        matica=matica+maticaa;
        if (n+2)==length(hmrb);
            n=length(hmrb);
        else (n+2)<length(hmrb); 
            n=n+2;
        end
        m=m+2;
    end
hmr111=matica;
matica=[0 0];
m=1;
n=2;
    while n<=length(gmrb);
        maticaa=gmrb(m:n);
        matica=matica+maticaa;
        if (n+2)==length(gmrb);
            n=length(gmrb);
        else (n+2)<length(gmrb); 
            n=n+2;
        end
        m=m+2;
    end
gmr111=matica;
Tmatica22=[hmr111; gmr111];
koeficienty22=Tmatica22*koeficienty44(1:2,1);

Tmatica88
koeficienty88
Tmatica44
koeficienty44
Tmatica22
koeficienty22

%+++++++++++++++++IDWT+++++++++++++++++++++++++++++++++++++++++++++++++++++
koeficientyaa=Tmatica22'*koeficienty22
koeficientybb=Tmatica44'*koeficienty44
povodnysignal=Tmatica88'*koeficienty88
end