Speed up FIR filter

26 views (last 30 days)
Peter
Peter on 17 Oct 2017
Answered: Christoph F. on 18 Oct 2017
Hi, I have to filter large amount of data with a FIR filter. My code works, but is rather slow. Is there a trick to speed it up (apart from FilterM)?
if true
ftype='bandpass';
Fn = SamplingRate/2; % Nyquist Frequency
HP=100; % High pass
LP=1000; % Low pass
Wp = [round(HP-0.1*HP) HP LP round(LP+0.1*LP)];
mags = [0 1 0];
devs = [0.05 0.01 0.05];
[n,Wn,beta,ftype] = kaiserord(Wp,mags,devs,SamplingRate);
n = n + rem(n,2);
hh = fir1(n,Wn,ftype,kaiser(n+1,beta),'scale');
FilteredSignal=filtfilt(hh,1,UnfilteredSignal); % filter step
end
  2 Comments
Peter
Peter on 17 Oct 2017
Thanks for your advice - you are absolutly right. The filtfilt stemmed from a former butterworth filter, where it is eesential...

Sign in to comment.

Answers (1)

Christoph F.
Christoph F. on 18 Oct 2017
As an answer:
Using filter() instead of filtfilt() to apply the filter will speed up the calculation by an order of magnitude.

Community Treasure Hunt

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

Start Hunting!