DWT edge/indexing problem
Bjorne, I am not exactly sure what you are trying to do but I can assure you that the simplest of DWT code is not more than 10 lines in Matlab. Here is how to do it:

approx = zeros(1, cols);
details = zeros(1, cols);

%for Haar Wavelet, Use filterbanks in Matlab, google it!

hi = ...
lo = ...

for i = 1: Level

   a = conv2(signal, lo);
   d = conv2(signal, hi);


   detail() =  downsample(d);
   approx() =  downsample(a);
   signal = downsample(a);

end


That is pretty much everything you need to compute DWT. As for the values between the parenthesis in detail and approximation, just fill in the indexes.