# How to plot poles, zeros and impulse response of a transfer function

I want to plot poles and zeros as well as impulse response of a transfer function that is given below:

$$H(z) = -0.0625z^4 + 0.25z^3 + 0.625z^2 + 0.25z -\frac{0.0625}{z^4}$$

For poles and zeros, I used MATLAB function residuez. However, I got error which is similar in impulse response plot.

code:

b = [-0.0625 0.25 0.625 0.25 -0.0625];
a = [0 0 0 0 1];
[R,p,C] = residuez(b,a); % for poles
y = impz(b,a); %for impulse response
figure(1);
stem(y);

Could someone help.

Thanks

Two hints:

1. The standard way of writing a transfer function in the $$\mathcal Z$$ domain is a rational function in $$z^{-1}$$, not in $$z$$. Try this
2. Use tf2zp() instead of residuez()

Here you go:

b = [-0.0625, 0.25, 0.625, 0.25, 0, 0, 0, 0, -0.0625];

a = 1;

% **** Plot impulse response  *****

[ImpResp,T] = impz(b,a,31);

figure(1), clf

plot(T,real(ImpResp),':bs','MarkerFaceColor','b','markersize',4)

title('Filter Impulse Response'), grid on, zoom on

% **** Plot poles & zeros  *****

[Z,P,Q] = tf2zpl(b,a);  % Calc poles and zeros

figure(2), clf

zplane(Z,P)

axis([-1.2,1.2, -1.2, 1.2]), zoom on

% Poles/Zeros

disp(' '), disp('Poles at (mag and degrees)');

[abs(P), angle(P)*180/pi]

disp(' '), disp('Zeros at (mag and degrees)');

[abs(Z), angle(Z)*180/pi]
• Hi Richard thanks. Commented Jun 28, 2020 at 11:44