function y=my3rdOrderIIR(A,B,x)
% This implements a 3rd order iir filter with a rational
% frequency characteristics, which has nominator coefficient vector A
% and denominator coefficient vector B. The transfer function is
% H(z)=(A(1)+A(2)/z+A(3)/z^2+A(4)/z^3)/(1+B(2)/z+B(3)/z^2+B(4)/z^3).
N=size(x,1);
y=zeros(N,2); % a signal with 2 channels of length N is assumed
for c=1:2; % filtering both channel data
for p=4:N; % realize the difference equation for the butterworth lowpass
s1=A(1)*x(p,c)+A(2)*x(p-1,c)+A(3)*x(p-2,c)+A(4)*x(p-3,c);
s2=-B(2)*y(p-1,c)-B(3)*y(p-2,c)-B(4)*y(p-3,c);
y(p,c)=s1+s2;
end;
end;