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

  1. function [wnout,z] = damp(a)
  2. % DAMP    Natural frequency and damping factor for continuous systems.
  3. %    [Wn,Z] = DAMP(A) returns vectors Wn and Z containing the
  4. %    natural frequencies and damping factors of A.   The variable A
  5. %    can be in one of several formats:
  6. %
  7. %        1) If A is square, it is assumed to be the state-space
  8. %           "A" matrix.
  9. %        2) If A is a row vector, it is assumed to be a vector of
  10. %           the polynomial coefficients from a transfer function.
  11. %        3) If A is a column vector, it is assumed to contain
  12. %           root locations.
  13. %
  14. %    When invoked without left hand arguments DAMP prints the 
  15. %    eigenvalues with their natural frequency and damping factor in a
  16. %    tabular format on the screen.
  17. %
  18. %    See also: EIG and DDAMP.
  19.  
  20. %     J.N. Little 10-11-85
  21. %    Revised 3-12-87 JNL
  22. %    Revised 7-23-90 Clay M. Thompson
  23. %    Copyright (c) 1986-93 by the MathWorks, Inc.
  24.  
  25. [m,n] = size(a);
  26. if (m == n)
  27.     r = esort(eig(a));
  28. elseif (m == 1)
  29.     r = esort(roots(a));
  30. elseif (n == 1)
  31.     r = a;
  32. else
  33.     error('Must be a vector or a square matrix.');
  34. end
  35. wn = abs(r);
  36. z = -cos(atan2(imag(r),real(r)));
  37.  
  38. if nargout==0,        % Print results on the screen.
  39.   disp('')
  40.   disp('   Eigenvalue        Damping        Freq. (rad/sec)')
  41.   disp('')
  42.   disp([r,z,wn])
  43.  
  44.   return % Suppress output
  45. end
  46. wnout = wn; 
  47.