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

  1. function [num, den] = ss2tf(a,b,c,d,iu)
  2. %SS2TF    State-space to transfer function conversion.
  3. %    [NUM,DEN] = SS2TF(A,B,C,D,iu)  calculates the transfer function:
  4. %
  5. %                NUM(s)          -1
  6. %        H(s) = -------- = C(sI-A) B + D
  7. %                DEN(s)
  8. %    of the system:
  9. %        .
  10. %        x = Ax + Bu
  11. %        y = Cx + Du
  12. %
  13. %    from the iu'th input.  Vector DEN contains the coefficients of the
  14. %    denominator in descending powers of s.  The numerator coefficients
  15. %    are returned in matrix NUM with as many rows as there are 
  16. %    outputs y.
  17. %
  18. %    See also: TF2SS.
  19.  
  20. %    J.N. Little 4-21-85
  21. %    Revised 7-25-90 Clay M. Thompson, 10-11-90 A.Grace
  22. %    Copyright (c) 1986-93 by the MathWorks, Inc.
  23.  
  24. error(nargchk(4,5,nargin));
  25. error(abcdchk(a,b,c,d));
  26.  
  27. [mc,nu] = size(d);
  28. if nargin==4,
  29.   if (nu<=1)
  30.     iu = 1;
  31.   else
  32.     error('IU must be specified for systems with more than one input.');
  33.   end
  34. end
  35.  
  36. den = poly(a);
  37. if ~isempty(b), b = b(:,iu); end
  38. if ~isempty(d), d = d(:,iu); end
  39.  
  40. % System is just a gain or it has only a denominator:
  41. if isempty(b) & isempty(c)
  42.     num = d;
  43.     if isempty(d) & isempty(a)
  44.         den = [];
  45.     end
  46.     return;
  47. end
  48.  
  49. nc = length(a);
  50. num = ones(mc, nc+1);
  51. for i=1:mc
  52.     num(i,:) = poly(a-b*c(i,:)) + (d(i) - 1) * den;
  53. end
  54.