Reconstruct the signal using wavelet
4 views (last 30 days)
Show older comments
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
0 Comments
Accepted Answer
Wayne King
on 6 Apr 2012
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.
More Answers (1)
Wayne King
on 6 Apr 2012
You are using the incorrect input to waverec. waverec expects that the input is the wavelet and scaling coefficients. However you are inputting the output of wrcoef, which is not the wavelet and scaling coefficients.
The output of wrcoef are projections onto vector subspaces, they are the same length as the input signal. Just set the d1 coefficients in the output from wavedec to zero to get what you are looing for and input that into waverec.
load noisdopp;
[C,L] = wavedec(noisdopp,8,'db8');
Cnew = C;
tmp = cumsum(L);
Cnew(tmp(end-2)+1:tmp(end-1)) = 0;
Rec_signal=waverec(Cnew,L,'db8');
plot(noisdopp,'k'); hold on;
plot(Rec_signal,'r','linewidth',2);
2 Comments
Alaa Gouda
on 13 Mar 2017
would you please can you help me in my code i decompose signal in 5 levels i want to remove A5 ,D1 How can I do it ???
See Also
Categories
Find more on Signal Analysis in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!