Why filtfilt when filter transfer function easy to calculate in frequecy domain

1 visualizzazione (ultimi 30 giorni)
My task requires zero-phase filtering. Why use the filtfilt command which increases the order of the filter by a factor of two when the same task could be done in the frequency domain without increasing filter order. All of my filtering is done off-line so the filter need not be causal. However, my results with filtfilt for similar filters are much smoother than my results with frequency domain filtering (ringing). I am guessing that I need to use a window on my time-series data to decrease the ringing.
  2 Commenti
Jan
Jan il 5 Feb 2013
What is your question? Could you post the used code such that we can see what exactly happens?
Paul
Paul il 5 Feb 2013
n = 1000;
nOrder = 4;
fc = 0.5; % normalized freq cutoff
y = randn(1,n);
y = [y zeros(1,200)]; %just to see some ringing
% matlab butterworth
[b,a] = butter(nOrder,fc);
y1 = filtfilt(b,a,y);
% frequency domain filtering
N = 2^nextpow2(length(y));
Y = fft(y,N);
%real signal is sym so we only need N/2 + 1
Y = Y(1:N/2+1);
% digital freq.
ff = linspace(0,1,N/2+1)/fc;
% butterworth filter
H = 1./sqrt((1+ff.^(2*nOrder)));
Y = Y.*H;
Y(2:end) = 2*Y(2:end);
y2 = real(ifft(Y,N));
y2 = y2(1:length(y));
figure;
plot(y);hold all;
plot(y1)
plot(y2)
legend('original','filtfilt','freq domain filter')

Accedi per commentare.

Risposte (0)

Community Treasure Hunt

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

Start Hunting!

Translated by