How to get the approximation from wdenoise

7 次查看(过去 30 天)
I am using the wdenoise app coming with the wavalet toolbox. After properly setting the wavelet parameters, this application provides a figure that plots the original signal, the denoised signal, and approximation. I am interested by the approximation curve. When I generate mathlab code from the app, it only generate the code for getting the denoised signal.
My question is : how to do for getting the approxiation curve in matlab from the output arguments of the wdenoise built-in function.
Thanks for your help.

采纳的回答

Kavya Vuriti
Kavya Vuriti 2019-8-12
The denoised coefficients can be obtained from the wdenoise function. Signal approximation can be done using these coefficients. Let me give an example of denoising with level 6 decomposition using ‘sym8’ wavelet.
[xden,denoisedcfs]=wdenoise( x,6, 'Wavelet', 'sym8') % xden is the denoised signal, x is the input signal
The final element of “denoisedcfs” cell array corresponds to approximation coefficients and the other elements corresponds to detail coefficients level by level. The wave decomposition vector can be found by using wavedec function. The wavelet used for denoising can be used to specify wavelet parameters for wavedec function.
[c,l] = wavedec(x,6,'sym8');
Signal approximation can be reconstructed using any level of detail coefficients and approximation coefficients. The code below reconstructs signal using 4th level detail coefficients and approximation coefficients. The detail coefficients in all other levels must be set to zero.
tmpcfs = denoisedcfs; %declare temporary cell array to use denoisedcfs for reconstruction
for ii = [1 2 3 5 6]
tmpcfs{ii} = zeros(numel(tmpcfs{ii}),1);
end
Assign the detail coefficients present in tmpcfs level by level to the wavelet decomposition vector c. Then use waverec function to reconstruct the signal approximation.
a=0;
for i=7:-1:1
c(a+1:a+numel(tmpcfs{1,i}))=tmpcfs{1,i}';
a=a+numel(tmpcfs{1,i});
end
X = waverec(c,l,'sym8'); %X is the signal approximation.
  3 个评论
Kavya Vuriti
Kavya Vuriti 2019-8-13
From your code, I found that you have not used wavedec function to find the decomposition vector.
[c,l] = wavedec(signal,6,'sym8');
Also in the waverec function, the second parameter must be "l" obtained from the above line of code.
X = waverec(c,l,'sym8');
pascal plisson
pascal plisson 2019-8-13
Thanks Kavya for your answer.
As I understood, Wavelet Signal Denoiser is just a GUI that invokes wavedec and waverec, and the approx which is plotted is just a reconstruction taken at a level roughly in the middle of levels.
Here after is an example displaying the reconstruction for each levels.
% create a noisy signal
sr = 44100;
t = 0:1/sr:0.01;
w = 2*pi*250;
s = [sin(w*t), sawtooth(w*t), square(w*t)];
noise = 0.2 * rand(1, length(s));
signal = s + noise;
% signal decomposition
wname = 'sym4';
level = 4;
[c,l] = wavedec(signal, level, wname);
% signal reconstruction
nl = numel(l);
for i=1:nl
cr = c;
cr(l(i)+1:end) = 0;
signalrec = waverec(cr, l, wname);
subplot(nl+1,1,i)
plot(signalrec);
title(sprintf('Reconstruction at level %i',i));
end
subplot(nl+1,1,nl+1);
plot(signal);
title('Original signal');
grid on;

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Denoising 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by