smoothing filter, how to avoid initial zero value
Afficher commentaires plus anciens
This is my problem: I have a vector that represents a trajectory. the first value is 420 and it decreases ti 150. this trajectory is noisiy so I filtered it using the "filter" function. the code is:
b=ones(1,10)/10; zfil = filter(b,1,z);
but when I plot zfil it starts from a zero value. How could I avoid this problem?
theese are the plots , the first is z, the second zfil
https://www.dropbox.com/s/k410rcpazz777gq/untitled.jpg
thanks!
Réponses (1)
Wayne King
le 22 Nov 2012
Modifié(e) : Wayne King
le 22 Nov 2012
One thing you can do is to compensate for the delay introduced by the smoothing filter. I'll create a noise signal x to illustrate, but substitute your signal for x.
b = ones(10,1)/10;
D = mean(grpdelay(b,1));
% let x be your input signal
x = randn(100,1);
% append some zeros to account for the delay
x = [x; zeros(round(D),1)];
y = filter(b,1,x);
y = y(round(D)+1:end);
Another thing you can try is to use filtfilt() but that squares the magnitude response of the filter
y = filtfilt(b,1,x);
Catégories
En savoir plus sur Smoothing and Denoising dans Centre d'aide et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!