Closed alireza-bina closed 3 years ago
Essentially, wavedec
calls dwt
function (NWaves equivalent: Fwt.Direct()
);
wrcoef
calls idwt
function (NWaves equivalent: Fwt.Inverse()
).
// x is input array
var C_L = new float[x.Length]; // for decomposition results
var A_D = new float[x.Length]; // for reconstruction results
var fwt = new Fwt(x.Length, new Wavelet("db5"));
int level = 9;
fwt.Direct(x, C_L, level);
fwt.Inverse(C_L, A_D, level);
I've also added another overloaded constructor in Wavelet
constructor accepting custom coefficients
var fwt = new Fwt(x.Length, new Wavelet(lo_dec, hi_dec, lo_rec, hi_rec));
//...
i write my code in matlab; x is signal; how to implement matlab code to nwave in c#? I try to use wiki example to implement a wavelet filter in C#, But I get confused where in example I can put the coefficient I get via MATLAB.
For example I get the d1:d9 and a9 from MATLAB as below
[C, L] = wavedec (x,9,'db5'); % Decomposition a9 = wrcoef ('a', C, L,'db5',9); % Approximate Component d9 = wrcoef ('d', C, L,'db5',9); % Detailed components d8 = wrcoef ('d', C, L,'db5',8); d7 = wrcoef ('d', C, L,'db5',7); d6 = wrcoef ('d', C, L,'db5',6); d5 = wrcoef ('d', C, L,'db5',5); d4 = wrcoef ('d', C, L,'db5',4); d3 = wrcoef ('d', C, L,'db5',3); d2 = wrcoef ('d', C, L,'db5',2); d1 = wrcoef ('d', C, L,'db5',1); y= d9+d8+d7+d6+d5+d4+d3+d2+d1;