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

  1. function s=mksys(v1,v2,v3,v4,v5,v6,v7,v8,v9,v10,v11,v12,v13,v14,v15,...
  2.     v16,v17,v18,v19,v20,v21,v22,v23,v24,v25,v26,v27,v28,v29,v30,v31,v32,...
  3.     v33,v34,v35,v36,v37,v38,v39,v40,v41,v42,v43,v44,v45,v46,v47,v48,v49,v50)
  4. % S=MKSYS(A,B,C,D) or 
  5. % S=MKSYS(V1,V2,...,VN, TY) packs matrices describing a system into TREE
  6. % vector S under variable names depending on the STRING TY as follows:
  7. % -----   -------------------------------  ---------------------------
  8. % TY      V1,V2,...,VN                     Description
  9. % -----   -------------------------------  ---------------------------
  10. % 'ss'    'a,b,c,d,ty'                        Standard Statespace (default)
  11. % 'des'   'a,b,c,d,e,ty'                      Descriptor System
  12. % 'tss'   'a,b1,b2,c1,c2,d11,d12,d21,d22,ty'  Two-port Statespace 
  13. % 'tdes'  'a,b1,b2,c1,c2,d11,d12,d21,d22,e,ty'Two-port Descriptor
  14. % 'gss'   'sm,dimx,dimu,dimy,ty'              General statespace
  15. % 'gdes'  'e,sm,dimx,dimu,dimy,ty'            General descriptor
  16. % 'gpsm'  'psm,deg,dimx,dimu,dimy,ty'         General polynom. sys. matrix
  17. % 'tf'    'num,den,ty'                        Transfer function
  18. % 'tfm'   'num,den,m,n,ty'                    Transfer function matrix
  19. % 'imp'   'y,ts,nu,ny'                        Impulse response
  20. % ----------------------------------------------------------------------
  21. % The BRANCH function recovers matrices packed into S, e.g., the 'c'
  22. % and 'a' matrices from a standard statespace system S are returned by
  23. % the command [C,A]=BRANCH(S,'c','a').  Alternatively, the command 
  24. % [AG,BG,CG,DG,TY]=BRANCH(S) returns all the matrices in the order in 
  25. % which they were originally packed.
  26. %
  27. % See also TREE, BRANCH, GRAFT
  28.  
  29. % R. Y. Chiang & M. G. Safonov 10/25/90    
  30. % Copyright (c) 1990 by the MathWorks, Inc.
  31. % All Rights Reserved.
  32. % ---------------------------------------------------------------------------
  33.  
  34. nin=nargin;
  35. sysmagic=27591;  % number installed in any system TREE in position 4
  36.                  % to distinguish it from ordinary tree vectors
  37.  
  38. % Determine TY and set NIN equal to number of input arguments other than TY 
  39. if nin<1
  40.   error('Too few input arguments')
  41. else 
  42.   eval(['ty=v' num2str(nin) ';'])
  43.   if isstr(ty),               % If TY is present
  44.      nin=nin-1;
  45.   else
  46.      ty='ss';                 % Default TY
  47.   end
  48. end
  49.  
  50. % Convert TY to lowercase
  51. ind=find(ty<'a');
  52. [rind,cind]=size(ind);
  53. if cind>0,
  54.    ty(ind)=ty(ind)+('a'-'A')*ones(1,cind);
  55. end
  56.  
  57. vars=vrsys(ty);
  58. nvars=max(size(find(vars==',')))+1;
  59. if nvars>nin,
  60.    error(['Too few input arguments for system type ' ty]),
  61. elseif nvars<nin,
  62.    error(['Too many input arguments for system type ' ty]),
  63. end
  64. vars = [vars ',ty'];
  65. temp=[];
  66. for i=1:nin,
  67.     temp = [temp ',v' num2str(i)];
  68. end
  69. temp=['s=tree(''' vars '''' temp ',''' ty ''');'];
  70. eval(temp)
  71. s(4)=sysmagic;
  72. %  -------- End MKSYS.M -----------RYC/MGS 10/25/90 %
  73.