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

  1. function k = acker(a,b,p)
  2. %ACKER    Pole placement gain selection using Ackermann's formula.
  3. %    K = ACKER(A,B,P)  calculates the feedback gain matrix K such that
  4. %    the single input system
  5. %            .
  6. %            x = Ax + Bu 
  7. %
  8. %    with a feedback law of  u = -Kx  has closed loop poles at the 
  9. %    values specified in vector P, i.e.,  P = eig(A-B*K).
  10. %
  11. %    See also PLACE.
  12. %
  13. %    Note: This algorithm uses Ackermann's formula.  This method
  14. %    is NOT numerically reliable and starts to break down rapidly
  15. %    for problems of order greater than 10, or for weakly controllable
  16. %    systems.  A warning message is printed if the nonzero closed loop
  17. %    poles are greater than 10% from the desired locations specified 
  18. %    in P.
  19.  
  20. %    Algorithm is from page 201 of:
  21. %    Kailath, T.  "Linear Systems", Prentice-Hall, 1980.
  22.  
  23. %    Copyright (c) 1986-93 by the MathWorks, Inc.
  24.  
  25. error(nargchk(3,3,nargin));
  26. error(abcdchk(a,b));
  27.  
  28. [m,n] = size(b);
  29. if n ~= 1
  30.     error('System must be single input');
  31. end
  32. p = p(:);        % Make sure roots are in a column vector
  33. [mp,np] = size(p);
  34. [m,n] = size(a);
  35. if (m ~= mp)
  36.     error('Vector P must have SIZE(A) elements');
  37. end
  38.  
  39. % Form gains using Ackerman's formula
  40. k = ctrb(a,b)\polyvalm(real(poly(p)),a);
  41. k = k(n,:);
  42.  
  43. % Check results. Start by removing 0.0 pole locations
  44. p = sort(p);
  45. i = find(p ~= 0);
  46. p = p(i);
  47. pc = sort(eig(a-b*k));
  48. pc = pc(i);
  49. if max(abs(p-pc)./abs(p)) > .1
  50.     disp('Warning: Pole locations are more than 10% in error.')
  51. end
  52.