I am using Excel. If I have an input and an output, and I know that a recursive band-pass filter produced the output, how can I can find the coefficients of that filter?


1 Answer 1


You can use an equation error method and get an estimation of the coefficients by solving an overdetermined system of linear equations. The transfer function of an IIR filter is given by


From (1), for given input and output sequences $x[n]$ and $y[n]$, respectively, the following equation must be satisfied:


where $*$ denotes convolution. Equation (2) can be written in matrix/vector form:


where $\mathbf{y}$ is the vector of the output signal, $\mathbf{b}$ and $\mathbf{a}$ are the unknown coefficient vectors (excluding $a[0]=1$), and $\mathbf{X}$ and $\mathbf{Y}$ are the convolution matrices consisting of the values of the input and output sequences, respectively. Equation (3) can be rewritten as


where $^T$ denotes transposition. The overdetermined system (4) can be solved in a least squares sense using standard methods, such as the one implemented in Matlab or Octave.

Note that in any case you need to estimate/choose the orders $M$ and $N$ of the numerator and denominator polynomials in (1). For most standard filters you have $M=N$.

This little Matlab/Octave script shows how it works:

x=randn(100,1);       % some input signal
a=[1 .3 -.4 .2 .1];   % denominator coefficients
b=[2 3 4 3 2];        % numerator coefficients
y=filter(b,a,x);      % filter output
M=3;                  % guessed numerator order
N=3;                  % guessed denominator order

% build matrices and solve overdetermined linear system
A = flipud(hankel(flipud(y(:)))); A1 = A(:,1); A = A(:,2:N+1);
B = flipud(hankel(flipud(x(:)))); B = B(:,1:M+1);
C = [-A,B];
c = C\A1;
a1 = [1;c(1:N)];
b1 = c(N+1:M+N+1);

% compare outputs of original and estimated filter
  • $\begingroup$ This method sims intuitive and I looked specifically for this question and answer. How come there is no standard implemention for it, nor a reference such as Yule Walker? $\endgroup$ Jan 8 at 20:14
  • $\begingroup$ @GideonGenadiKogan: Maybe there is, I might just not know about it. $\endgroup$
    – Matt L.
    Jan 8 at 21:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.