# FIR filter approximation using a continuous time dynamical system

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?

• I don't think this is the suitable site for such questions. Please check stackoverflow.com or electronics.stackexchange.com. – Meshal Sep 21 '15 at 16:35
• @Meshal I doubt that the sites you link are more suitable than this one. Perhaps better : dsp.stackexchange.com – leonbloy Sep 21 '15 at 16:45
• @leonbloy Even better! Actually I just knew about the DSP site. Thanks. – Meshal Sep 21 '15 at 16:46
• I would think that this can be formulated mathematically and in the framework of system theory – Jose Ospina Sep 21 '15 at 17:15
• Ok, I have posted it here dsp.stackexchange.com/questions/25969/…. In any case, I would hope mathematicians would leave their cozy abstract environment, and be more willful of confronting their conceptual framework with banal real world applications. – Jose Ospina Sep 22 '15 at 7:03