clear all;
close all hidden;
pack;

fs = 1e4;   % Sampling frequency, in Hz
N = 32;     % Number of samples
f1 = 100;   % Sine frequency one, in Hz
f2 = 400;   % Sine frequency two, in Hz

t = [0 : 1/fs : (N-1)/fs];
x = sin(2*pi*f1*t) + cos(2*pi*f2*t);

[C, L] = wavedec(x, 3, 'sym4');

D3 = detcoef(C, L, 3);
A3 = appcoef(C, L, 'sym4', 3);

D2 = detcoef(C, L, 2);
A2 = appcoef(C, L, 'sym4', 2);

D1 = detcoef(C, L, 1);
A1 = appcoef(C, L, 'sym4', 1);

mtx = WavMat(wfilters('sym4'), N, 3);
res = mtx * x.';

I = eye(N);
[WaveMtx_C WaveMtx_L] = wavedec2(I, 3, 'sym4');
WaveMtx_D = detcoef2(WaveMtx_C, WaveMtx_L, 3);
WaveMtx_A = appcoef2(WaveMtx_C, WaveMtx_L, 'sym4', 3);

[cA cD] = dwt(x, 'sym4');


mtx = zeros(52, 32);
for i = 1 : 32
    ulaz = zeros(1, 32);
    ulaz(i) = 1;

    izlaz = wavedec(ulaz, 3, 'sym4');
    
    mtx(1 : length(izlaz), i) = izlaz;
end

mtx2 = WaveMtx(32, 3, 'sym4');

max(max(abs(mtx - mtx2)))

izlaz1 = mtx * x.';
izlaz2 = wavedec(x, 3, 'sym4').';
izlaz = [izlaz1, izlaz2];
max(abs(izlaz1 - izlaz2))
