How to get the approximation from wdenoise

조회 수: 4 (최근 30일)
pascal plisson
pascal plisson 2019년 8월 9일
댓글: pascal plisson 2019년 8월 13일
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에서 Signal Analysis에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by