home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 10 / 10.iso / l / l455 / 10.ddi / CONTROL.DI$ / PZMAP.M < prev    next >
Encoding:
Text File  |  1993-03-11  |  2.3 KB  |  81 lines

  1. function [pout,z] = pzmap(a,b,c,d)
  2. %PZMAP    Plot pole-zero map of continuous-time linear system.
  3. %    PZMAP(A,B,C,D) computes the eigenvalues and transmission zeros of
  4. %    the continuous-time state-space system (A,B,C,D) and plots them in
  5. %    the complex s-plane.  The poles are plotted as x's and the zeros 
  6. %    are plotted as o's.  
  7. %
  8. %    PZMAP(NUM,DEN) computes the poles and zeros of the SISO polynomial
  9. %    transfer function G(s) = NUM(s)/DEN(s) where NUM and DEN contain 
  10. %    the polynomial coefficients in descending powers of s.  If the 
  11. %    system has more than one output, then the transmission zeros are 
  12. %    computed.
  13. %
  14. %    PZMAP(P,Z) plots the poles, P, and the zeros, Z, in the complex 
  15. %    plane.  P and Z must be column vectors.  When invoked with left
  16. %    hand arguments,
  17. %        [P,Z] = PZMAP(NUM,DEN)  or  [P,Z] = PZMAP(A,B,C,D)
  18. %    returns the poles and transmission zeros of the system in the 
  19. %    column vectors P and Z.  No plot is drawn on the screen.  
  20. %
  21. %    The function SGRID or ZGRID can be used to plot lines of constant
  22. %    damping ratio and natural frequency in the s or z plane.
  23. %
  24. %    See also: RLOCUS,SGRID,ZGRID,EIG,TZERO,SS2ZP, and TF2ZP.
  25.  
  26. %    Clay M. Thompson  7-12-90
  27. %    Revised ACWG 6-21-92
  28. %    Copyright (c) 1986-93 by the MathWorks, Inc.
  29.  
  30. if (nargin==0), eval('exresp(''pzmap'')'), return, end
  31.  
  32. error(nargchk(2,4,nargin));
  33. if (nargin==3), error('Wrong number of input arguments.'); end
  34.  
  35. % --- Determine which syntax is being used ---
  36. if (nargin==2),
  37.     [nd,md] = size(b);
  38.     if (md<=1),    % Assume Pole-Zero form
  39.         p = a; z = b;
  40.     else,        % Transfer function form
  41.         [num,den] = tfchk(a,b);
  42.         p = roots(den);
  43.         [nn,mn] = size(num);
  44.         if nn==1,
  45.             z = roots(num);
  46.         else
  47.             [a,b,c,d] = tf2ss(num,den);
  48.             z = tzero(a,b,c,d);
  49.         end
  50.     end
  51.  
  52. else            % State space system 
  53.     error(abcdchk(a,b,c,d));
  54.     p = eig(a);
  55.     z = tzero(a,b,c,d);
  56.  
  57. end
  58.  
  59. % If no output arguments then plot graph
  60. if nargout==0,
  61.  
  62.     if ~isempty(z)
  63.         plot(real(p),imag(p),'x',real(z),imag(z),'o')
  64.     else
  65.         plot(real(p),imag(p),'x')
  66.     end
  67.     
  68.     xlabel('Real Axis'), ylabel('Imag Axis')
  69.  
  70.     % Draw real and imag axis
  71.     status = ishold;
  72.     hold on
  73.     limits = axis;
  74.     plot([0 0],limits(3:4),'w:',limits(1:2),[0 0],'w:')
  75.     
  76.     if ~status, hold off, end    % Return hold to previous status
  77.     return
  78. end
  79.  
  80. pout = p;
  81.