%  Example 2.5.  Computes the coefficients in the impulse response.
clear
%  Define the transfer function model.
nu=[1 1];
de=conv([1 2],[1 2 5]);
%  Compute the partial fraction expansion
[r,p,k]=residue(nu,de);
%  Compute the coefficients in the impulse response.
%  Note:  The order of the poles is observed before generating the 
%    remainder of the code.
c1=r(3)
c2=r(1)
c3=r(2)
c4=0
c5=real(r(1))*2
c6=-imag(r(1))*2
%  The coefficients are checked by comparing with the simulated impulse
%  response.
t=0:.05:5;
g=impulse(nu,de,t);
g1=real(c1*exp(p(3)*t)+c2*exp(p(1)*t)+c3*exp(p(2)*t));
g2=c1*exp(-2*t)+c5*exp(-t).*cos(2*t)+c6*exp(-t).*sin(2*t);
%  Plot the simulated impulse responses.
figure(1)
clf
plot(t,g,t,g1,t,g2)
xlabel('Time (sec)')
ylabel('Magnitude')
grid