# Wavelet transform wavdec returns matrix of the wrong size

I have a question regarding the wavdecand dwt functions in MATLAB.

I am using wavdec(y,3,db4) on a size 1024 signal, which means I am trying to compute the third level db4 transform of the size 1024 signal y. If I am thinking about this correctly, theoretically the returned matrix after the transform should also be of size 1024.

However, when I perform the transform, the matrix I get returned is size 1044, which is 20 samples bigger than my original matrix.

Would anyone please be able to explain to me why this is happening?

## 1 Answer

this is due to the fact that the default boundary handling is symmetric extension, which requires several coefficients more in order to achieve the perfect reconstruction. Try

dwtmode('per')

to use periodization to set the representation to be non-redundant. This will however be non-redundant only for input signal lengths being integer multiples of 2^J, where J is number of wavedec levels. Otherwise, very strange padding is used in every step of the wavedec.

P.S.: Sorry for the late answer :)