Azzera filtri
Azzera filtri

Reconstruct the signal using wavelet

5 visualizzazioni (ultimi 30 giorni)
Fuad Numan
Fuad Numan il 6 Apr 2012
Commentato: Alaa Gouda il 13 Mar 2017
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

Risposta accettata

Wayne King
Wayne King il 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.
  1 Commento
Fuad Numan
Fuad Numan il 6 Apr 2012
Oh, sorry I missed that one.
Now it is ok
tmp(end-2)+1 = 1111
tmp(end-1) = 2117
which confirms the length of D1
Thank you

Accedi per commentare.

Più risposte (1)

Wayne King
Wayne King il 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 Commenti
Fuad Numan
Fuad Numan il 6 Apr 2012
Thank you Wayne
This is my first use of wavlet, this definitely solves my problem, but still cant get it. the indices you put to remove the D1 coefficients are floot (not integer).
how could I know in which range of Cnew indices each coefficient located in.
As per your script,
tmp(end-2)+1 = 3.8112
tmp(end-1) = 0.6585
while the length of D1 is 1007, given from
[D1,D2,D3,D4,D5,D6,D7,D8]=detcoef(C2,L2,[1 2 3 4 5 6 7 8]);
Alaa Gouda
Alaa Gouda il 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 ???

Accedi per commentare.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by