FIR filter approximation using a continuous time dynamical system

292 Views Asked by At

How can you approximate a Finite Impulse Discrete filter (FIR) using a continuous time linear dynamical system?

I am seeing this problem using Matlab, where the resulting continuous system (obtained using the d2c Matlab function) is almost unstable and provides a step response that is totally different than the one expected when simulated using Simulink.

As an example, try to obtain a continuous time dynamical system whose response is similar to a moving average of the last 25 samples (sampled at 100 Hz).

This is the Matlab Code I am using

  n = 25;
  k = 1/n*ones(1,n);
  n = length(k);
  A = diag(ones(1,n-1),1);
  B = [zeros(1,n-1) 1]'
  C = k;
  D = 0

  sys = ss(A,B,C,D,0.01)
  sysc = d2c(sys,'tustin')

But, what happens is that you then simulate sysc and sys using the Simulink continuous and discrete linear systems blocks and the output of sysc goes unstable.

Is there a fundamental complexity/impossibility of doing this conversion? How can it be overcame?