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

  1. % function out = starp(top,bot,dim1,dim2)
  2. %
  3. %   Redheffer star-product of two SYSTEM/VARYING/CONSTANT
  4. %   matrices. TOP represents the top matrix and BOT represents
  5. %   the bottom matrix. DIM1 is the number of inputs to connect
  6. %   to the BOT matrix and DIM2 is the number of outputs to the
  7. %   TOP matrix. DIM1 and DIM2 are optional, if they are not 
  8. %   provided it is assumed that the desired interconnection
  9. %   is a linear fractional transformations and the correct
  10. %   inputs/outputs are closed.
  11. %
  12. %                _________ 
  13. %       <-------|         |<--------
  14. %               |   TOP   |
  15. %           /---|_________|<---
  16. %      dim1 |                 | dim2
  17. %           |                 |                  
  18. %           |                 |                 /---------\
  19. %            \________________|___       <------|         |<-------
  20. %                             |  |              |   OUT   |
  21. %                             |  |       <------|         |<-------
  22. %            _________________|  |              \_________/
  23. %           /                    |
  24. %           |   __________       |
  25. %           |--|          |<-----/
  26. %              |   BOT    |
  27. %       <------|__________|<-------
  28. %
  29. %
  30. %   See also: MADD, MMULT, and SYSIC. 
  31.  
  32. function out = starp(mat1,mat2,dim1,dim2)
  33.   if nargin < 2 | nargin == 3
  34.     disp('usage: out = starp(top,bot,dim1,dim2)')
  35.     return
  36.   else
  37.     [onetype,onerows,onecols,onenum] = minfo(mat1);
  38.     [twotype,tworows,twocols,twonum] = minfo(mat2);
  39.     if nargin == 2
  40.       if onerows > twocols
  41.         if tworows >= onecols
  42.           error(['incorrect dimensions']);
  43.           return
  44.         else
  45.           dim1 = twocols;
  46.           dim2 = tworows;
  47.         end
  48.       elseif onerows == twocols
  49.         if onecols == tworows
  50.           dim1 = onerows;
  51.           dim2 = onecols;
  52.         else
  53.           error(['incorrect dimensions']);
  54.         end
  55.       else
  56.         if tworows > onecols
  57.           dim1 = onerows;
  58.           dim2 = onecols;
  59.         else
  60.           error(['incorrect dimensions']);
  61.         end
  62.       end
  63.     end
  64.     if (onetype == 'syst' & twotype == 'vary') | ...
  65.          (onetype == 'vary' & twotype == 'syst')
  66.       error('star product of system and varying not allowed')
  67.       return
  68.     elseif dim1 > min([onerows twocols])
  69.       error('incompatible dimensions')
  70.       return
  71.     elseif dim2 > min([onecols tworows])
  72.       error('incompatible dimensions')
  73.       return
  74.     end
  75.     if onetype == 'vary'
  76.       if twotype == 'vary'
  77. %       both VARYING
  78.         code = indvcmp(mat1,mat2);
  79.         if code == 1
  80.           [nr1,nc1] = size(mat1);
  81.           [nr2,nc2] = size(mat2);
  82.           omega1 = mat1(1:onenum,nc1);
  83.           omega2 = mat2(1:twonum,nc2);
  84.           npts = onenum;
  85.           nrout = onerows + tworows - dim1 - dim2;
  86.           ncout = onecols + twocols - dim1 - dim2;
  87.           out = zeros(nrout*npts+1,ncout+1);
  88.           out(nrout*npts+1,ncout+1) = inf;
  89.           out(nrout*npts+1,ncout) = onenum;
  90.           out(1:npts,ncout+1) = omega1;
  91.           fone = (npts+1)*onerows;
  92.           ftwo = (npts+1)*tworows;
  93.           fout = (npts+1)*nrout;
  94.           pone = 1:onerows:fone;
  95.           ptwo = 1:tworows:ftwo;
  96.           pout = 1:nrout:fout;
  97.           ponem1 = pone(2:npts+1) - 1;
  98.           ptwom1 = ptwo(2:npts+1) - 1;
  99.           poutm1 = pout(2:npts+1) - 1; 
  100.           for i=1:npts
  101.             tmp1 = mat1(pone(i):ponem1(i),1:onecols);
  102.             tmp2 = mat2(ptwo(i):ptwom1(i),1:twocols);
  103.             out(pout(i):poutm1(i),1:ncout) = ...
  104.                genlft(tmp1,tmp2,dim1,dim2);
  105.           end
  106.         else
  107.           error('inconsistent varying data')
  108.           return
  109.         end
  110.       else
  111. %       VARYING & CONSTANT
  112.         [nr1,nc1] = size(mat1);
  113.         omega = mat1(1:onenum,nc1);
  114.         npts = onenum;
  115.         nrout = onerows + tworows - dim1 - dim2;
  116.         ncout = onecols + twocols - dim1 - dim2;
  117.         out = zeros(nrout*npts+1,ncout+1);
  118.         out(nrout*npts+1,ncout+1) = inf;
  119.         out(nrout*npts+1,ncout) = onenum;
  120.         out(1:npts,ncout+1) = omega;
  121.         fone = (npts+1)*onerows;
  122.         fout = (npts+1)*nrout;
  123.         pone = 1:onerows:fone;
  124.         pout = 1:nrout:fout;
  125.         ponem1 = pone(2:npts+1) - 1;
  126.         poutm1 = pout(2:npts+1) - 1; 
  127.         for i=1:npts
  128.           tmp1 = mat1(pone(i):ponem1(i),1:onecols);
  129.           out(pout(i):poutm1(i),1:ncout) = ...
  130.              genlft(tmp1,mat2,dim1,dim2);
  131.         end
  132.       end
  133.     elseif onetype == 'cons'
  134.       if twotype == 'vary'
  135. %       CONSTANT*VARYING
  136.         [nr2,nc2] = size(mat2);
  137.         omega = mat2(1:twonum,nc2);
  138.         npts = twonum;
  139.         nrout = onerows + tworows - dim1 - dim2;
  140.         ncout = onecols + twocols - dim1 - dim2;
  141.         out = zeros(nrout*npts+1,ncout+1);
  142.         out(nrout*npts+1,ncout+1) = inf;
  143.         out(nrout*npts+1,ncout) = twonum;
  144.         out(1:npts,ncout+1) = omega;
  145.         ftwo = (npts+1)*tworows;
  146.         fout = (npts+1)*nrout;
  147.         ptwo = 1:tworows:ftwo;
  148.         pout = 1:nrout:fout;
  149.         ptwom1 = ptwo(2:npts+1) - 1;
  150.         poutm1 = pout(2:npts+1) - 1; 
  151.         for i=1:npts
  152.           tmp2 = mat2(ptwo(i):ptwom1(i),1:twocols);
  153.           out(pout(i):poutm1(i),1:ncout) = ...
  154.              genlft(mat1,tmp2,dim1,dim2);
  155.         end
  156.       elseif twotype == 'cons'
  157. %       CONSTANT & CONSTANT
  158.         out = genlft(mat1,mat2,dim1,dim2);
  159.       else
  160. %       CONSTANT*SYSTEM
  161.         out = redstar(mat1,mat2,dim1,dim2);
  162.       end
  163.     else
  164.       if twotype == 'cons'
  165. %       SYSTEM*CONSTANT
  166.         out = redstar(mat1,mat2,dim1,dim2);
  167.       else
  168. %       SYSTEM*SYSTEM
  169.         out = redstar(mat1,mat2,dim1,dim2);
  170.       end
  171.     end
  172.   end
  173. %
  174. % Copyright MUSYN INC 1991,  All Rights Reserved
  175.