image thumbnail
from Pole-Zero plot by Zhihua He
Better looking Pole-Zero plot.

PZ_plot(Mode,a,b);
function PZ_plot(Mode,a,b);
%---------------------------------------------------------------------------------------------
%PZ_plot(MODE,A,B) plots the zeros and poles of the Direct Form Digital Filter or ARMA process
%
%  y(n) + a[1]*y[n-1] + ... + a[p]*y[n-p] =x[n] + b[1]*x[n-1] + ... + b[q]*x[n-q]
%
% in 2 optional modes.
%
% MODE=1, input A is a vector of poles and B is vector of the zeros.
% MODE=2, input A=[a[1],a[2],...a[p]], B=[b[1],b[2],...b[q]], are the coefficients of the
% denominator and numerator polynomials, respectively. 
% NOTE: a[0],b[0]=1 are not included in the vector.
%
%   Usage Examples,
%
%   a=[0.9,0.8,0.1];
%   b=[0.2,0.1];
%   PZ-plot(2,a,b);
%
%   z=0.9*[exp(j*pi/5), exp(j*2*pi/5)];
%   p=conj(1./z);
%   PZ_plot(1,p,z);
%
%   Zhenhai Wang <zhenhai@ieee.org>
%   Version 1.00
%   October, 2002
%---------------------------------------------------------------------------------------------

if (nargin <3),
 error('Please see help for INPUT DATA.');
end;

t = (0:1/500:1)'*2*pi;
for m=1:5
    l=(6-m)/5;
    x(:,m) = l*sin(t);
    y(:,m) = l*cos(t);
    plot(x(:,m),y(:,m),'k--');hold on;
    text(m*0.15,-m*0.15,num2str(m*0.2));
end
plot(x(:,1),y(:,1),'k');
axis equal
axis off
line([-1.2 1.2],[0 0],'color','k');
line([0 0],[-1.2 1.2],'color','k');
hold on;
plot(1.2,0,'>',0,1.2,'^','MarkerFaceColor','k','MarkerEdgeColor','k'); 
text(1.1,0.1,'Re','FontAngle','italic','FontName','Euclid Fraktur');
text(1.23,0.11,'(z)');
text(0.08,1.1,'Im','FontAngle','italic','FontName','Euclid Fraktur');
text(0.21,1.11,'(z)');
text(-1.2,0.72,'Unit Circle');

if Mode==1
    a = poly(a);
    a = a(2:length(a));
    b = poly(b);
    b = b(2:length(b));
end
a = a(:);
b = b(:);
p = length(a);
q = length(b);
if p ~= 0,
    pl=roots([1;a]);
    plot(real(pl),imag(pl),'x','MarkerFaceColor','r','MarkerEdgeColor','r','MarkerSize',8,'LineWidth',2);
end
if q ~= 0,
    zr=roots([1;b]);
    plot(real(zr),imag(zr),'o','MarkerEdgeColor','b','MarkerSize',5,'LineWidth',1);
end
if p-q==0
    return;
end
if q-p<0
    Mkr='o';
elseif q-p>0
    Mkr='x';
end
for m=1:abs(p-q)
    plot(0,0,Mkr,'MarkerEdgeColor','g','MarkerSize',5+4*(m-1),'LineWidth',1);
end

Contact us at files@mathworks.com