Computing the impulse response of a system with complex poles (Example 1)
This example shows three different ways to compute the impulse response.
Contents
Define system coefficients
Difference equation: y(n) = x(n) - 2.5 x(n-1) + y(n-1) - 0.7 y(n-2)
b = [1 -2.5]; a = [1 -1 0.7];
Compute impulse response directly from different equation
Use the MATLAB function 'filter' to compute the impulse response
L = 30; x = [1 zeros(1, L)]; h1 = filter(b, a, x); figure(1) clf n = 0:L; stem(n, h1, '.'); title('Impulse response computed using difference equation') ax = [-1 L -2.5 2.5]; axis(ax) box off
Compute impulse response using partial fraction expansion
Use MATLAB function 'residue' to find the poles and residues.
[r,p,k] = residue(b,a) % r = % 0.5000 + 1.4907i % 0.5000 - 1.4907i % % p = % 0.5000 + 0.6708i % 0.5000 - 0.6708i % % k = % [] h2 = r(1)*p(1).^n + r(2)*p(2).^n; figure(1) clf stem(n, h2, '.') title('Impulse response computed using partial fraction expanstion') axis(ax) box off
r = 0.5000 + 1.4907i 0.5000 - 1.4907i p = 0.5000 + 0.6708i 0.5000 - 0.6708i k = []
Verify that h2 is the same as h1
max(abs(h1 - h2))
% This is zero to machine precision
ans = 8.8818e-16
Compute impulse response using cosine formula
h3 = 2*abs(r(1))*(abs(p(1)).^n).*cos(angle(p(1))*n+angle(r(1))); figure(1) clf stem(n, h3, '.') title('Impulse response computing using cosine formula') axis(ax) box off
Verify that h3 is the same as h1
max(abs(h1 - h3))
% This is zero to machine precision
ans = 9.8532e-16
Plot all
figure(2) clf subplot(3, 1, 1) stem(n, h1, 'k.') title('Impulse response computed using difference equation') axis(ax) box off subplot(3, 1, 2) stem(n, h2, 'k.') title('Impulse response computed using partial fraction expanstion') axis(ax) box off subplot(3, 1, 3) stem(n, h3, 'k.') title('Impulse response computing using cosine formula') axis(ax) box off orient tall print -dpdf ComplexPoles_1