# Differences between matlab's 'impulse' and 'lsim' command; create impulse response

I've got following problem:

assume you've this continous system 1st order:

$$H(s) = \frac{1}{1+s}$$

s = tf('s');
sys = 1/(1+s);


I'm going to discretize this system via impulse invariant transformation and plot the results.

sysD = c2d(sys,1e-3,'impulse');
impulse(sys);
hold all;
impulse(sysD);


So this seems to work.

If I try to create the impulse response for 7 seconds manually I use:

imp = zeros(1,7*1e3);
imp(1) = 1;
t = 0:1e-3:7-1e-3;
y = lsim(sys,imp,t);
plot(t,y)


Unfortunately this is not the response I expected. The gain seems to be scaled by the samplerate 1e3.

So the question is: What does impulse do since this response should be correct. lsim uses the filter command and simply passes the nominator and denominator to filter I think. Is the dirac impulse (or kronecker delta) wrong? Must it be scaled by the samplerate?

I discovered the whole thing, because I wanted to design a very simple digital filter. I knew the responses of time continuous systems, so I thought it would be easy to discretize the transfer function and use the coefficients of the digital transfer function that can be used by filter or in a dsp application.

What is wrong?

Thank you very much!

Indeed the lsim function is returning scaled values. You might also notice that it is connected to the gain $k$ of your filter:

[z,p,k] = tf2zpk(sysD.num{1}, sysD.den{1});


That will return:

k=0.002

You can scale it back by the sampling period as you noticed.

• How to scale it back using OP lsim code? What should be modified? – Unknown123 Nov 20 '18 at 3:47