Coding wavelets the easy way

% clear workspace
clear all
% Prepare data
load PieceRegSig;
u.s = sig;
u.d = 0;
% Prepare the filters
load Daub4;
h.s = h;
h.d = 0; % degree is 3
g.s = g;
g.d = 0;
rh.s = rh;
rh.d = 3; % degree is -3
rg.s = rg;
rg.d = 3;
scale = 6;
%-----------------
WT = WaveTransform(u,h,g,scale);
v = InvWaveTransform(WT,rh,rg,scale);
l = length(sig);
w = v.s(v.d+1:v.d+l);
figure(1);plot(w-sig);

and here is the plot of the reconstruction error:

RecursiveReconstruction