Clear Filters
Clear Filters

Manual implementation of filtfilt(b,a,x) or filter(b,a,x,zi)?

10 views (last 30 days)
Hi!
I want to implement 'filtfilt' function in C. 'filtfilt' function has 'filter' as its subfunction.
I could implement y=filter(b,a,x) as follows:
y(n) = b(1)*x(n) + b(2)*x(n-1) + ... + b(nb+1)*x(n-nb) - a(2)*y(n-1) - ... - a(na+1)*y(n-na).........equation-1
Now accept the fact that I already have "zi" , how to implement y=filter(b,a,x,zi)? where, Zi=initial condition of the delay. What would be the change in equation-1 after the application of Zi?
Or is there any other way to implement directly filtfilt(b,a,x) in C?
Thanks!

Answers (1)

Jan
Jan on 13 Feb 2017
For an implementation of filter() in C see https://www.mathworks.com/matlabcentral/fileexchange/32261-filterm . Inside FilterM.m you find code for an M-version also. In opposite to Matlab's filter() this C-version can operate in backward direction also to save the time for the creation of a reversed signal in filtfilt().

Community Treasure Hunt

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

Start Hunting!