MATLAB: Reconstruct the signal using wavelet

decomposereconstructwavelet

I have a noisy signal , i want to decompose it and reconstruct a specific sub-band frequencies;
[C2,L2]=wavedec(xn,8,'db8');
% approximation coefficients
A1=wrcoef('a',C2,L2,'db8',1);
A2=wrcoef('a',C2,L2,'db8',2);
A3=wrcoef('a',C2,L2,'db8',3);
A4=wrcoef('a',C2,L2,'db8',4);
A5=wrcoef('a',C2,L2,'db8',5);
A6=wrcoef('a',C2,L2,'db8',6);
A7=wrcoef('a',C2,L2,'db8',7);
A8=wrcoef('a',C2,L2,'db8',8);
%detail coefficients
D1=wrcoef('d',C2,L2,'db8',1);
D2=wrcoef('d',C2,L2,'db8',2);
D3=wrcoef('d',C2,L2,'db8',3);
D4=wrcoef('d',C2,L2,'db8',4);
D5=wrcoef('d',C2,L2,'db8',5);
D6=wrcoef('d',C2,L2,'db8',6);
D7=wrcoef('d',C2,L2,'db8',7);
D8=wrcoef('d',C2,L2,'db8',8);
I have used "waverec" function to reconstruct the whole frequencies except the detail 1 (D1), I used
C=[A8;D8;D7;D6;D5;D4;D3;D2];
L=[length(A8);length(D8);length(D7);length(D6);length(D5);length(D4);length(D3);length(D2);length(xn)];
Rec_signal=waverec(C,L,'db8');
The resulted Rec_signal is too much different from the original signal even not close;
Is that a correct reconstruction code, or i have to sum the coefficients together.
I also want to try omitting other coefficients and rebuild the signal till i get what i want.
appreciate your help

Best Answer

Are you sure you are getting tmp from
tmp = cumsum(L);
That output cannot be a non-integer, please show me your code and give me the length of your input signal.
Related Question