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

  1. function [a,b,c,d] = series(a1,b1,c1,d1,a2,b2,c2,d2,e,f)
  2. %SERIES Series connection of two systems.  
  3. %
  4. %        u --->[System1]--->[System2]----> y
  5. %
  6. %    [A,B,C,D] = SERIES(A1,B1,C1,D1,A2,B2,C2,D2) produces an aggregate
  7. %    state-space system consisting of the series connection of systems
  8. %    1 and 2 that connects all the outputs of system 1 connected to 
  9. %    all the inputs of system 2, u2 = y1.  The resulting system has 
  10. %    the inputs of system 1 and the outputs of system 2.
  11. %
  12. %    [A,B,C,D] = SERIES(A1,B1,C1,D1,A2,B2,C2,D2,OUTPUTS1,INPUTS2) 
  13. %    connects the two system in series such that the outputs of system
  14. %    1 specified by OUTPUTS1 are connected to the inputs of system 2 
  15. %    specified by INPUTS2.  The vectors OUTPUTS1 and INPUTS2 contain 
  16. %    indexes into the output and inputs of system 1 and system 2 
  17. %    respectively.
  18. %    [NUM,DEN] = SERIES(NUM1,DEN1,NUM2,DEN2) produces the SISO system
  19. %    in transfer function form obtained by connecting the two SISO 
  20. %    transfer function systems in series.
  21. %
  22. %    See also: APPEND,PARALLEL,FEEDBACK and CLOOP.
  23.  
  24. %    Clay M. Thompson 6-29-90
  25. %    Copyright (c) 1986-93 by the MathWorks, Inc.
  26.  
  27. error(nargchk(4,10,nargin));
  28.  
  29. % --- Determine which syntax is being used ---
  30. if (nargin == 4)  % Form Series connection of T.F. system ---
  31.   [num1,den1] = tfchk(a1,b1); [num2,den2] = tfchk(c1,d1);
  32.   a = conv(num1,num2);
  33.   b = conv(den1,den2);
  34.  
  35. elseif ((nargin>=5) & (nargin<=7)) | (nargin==9)
  36.   error('Wrong number of input arguments.');
  37.  
  38. elseif (nargin==8) | (nargin==10)  % State space systems 
  39.   error(abcdchk(a1,b1,c1,d1));
  40.   error(abcdchk(a2,b2,c2,d2));
  41.  
  42. % Get number of inputs and outputs
  43.   [ny1,nu1] = size(d1);
  44.   if (nu1 == 0), [dum, nu1] = size(b1);  [ny2, dum] = size(c1); end
  45.   [ny2,nu2] = size(d2);
  46.   if (nu2 == 0), [dum, nu2] = size(b2); [ny2, dum] = size(c2); end
  47.  
  48.   if (nargin == 8) % State space systems w/o selection vectors
  49.     inputs1 = [1:nu1];     outputs1 = [1:ny1];
  50.     inputs2 = [1:nu2]+nu1; outputs2 = [1:ny2]+ny1; 
  51.   end
  52.   if (nargin == 10) % State space systems with selection vectors
  53.     inputs1 = [1:nu1];     outputs1 = e;
  54.     inputs2 = f+nu1;  outputs2 = [1:ny2]+ny1;
  55.   end
  56.   
  57.   % Check sizes
  58.   if (length(outputs1)~=length(inputs2))
  59.     error('Series connection sizes don''t match.'); end
  60.  
  61.   % --- Series Connection ---
  62.   [a,b,c,d] = append(a1,b1,c1,d1,a2,b2,c2,d2);
  63.   [a,b,c,d] = cloop(a,b,c,d,outputs1,inputs2);
  64.   [a,b,c,d] = ssselect(a,b,c,d,inputs1,outputs2);
  65. end
  66.