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

  1. % function sys = redstar(top,bot,dim1,dim2)
  2. %
  3. %   interconnects two SYSTEM matrices as a Redheffer product.
  4. %   main subroutine for STARP.
  5. %
  6. %   See also: STARP.
  7.  
  8. function sys = redstar(top,bot,dim1,dim2)
  9.  if nargin < 4
  10.    disp('usage: sys = redstar(top,bot,dim1,dim2)')
  11.    return
  12.  end
  13.  [toptype,toprows,topcols,topnum] = minfo(top);
  14.  [bottype,botrows,botcols,botnum] = minfo(bot);
  15.  if toptype == 'syst'
  16.    topstates = topnum;
  17.    acttop = top(1:topnum+toprows,1:topnum+topcols);
  18.  elseif toptype == 'cons'
  19.    topstates = 0;
  20.    acttop = top;
  21.  else
  22.    error('VARYING matrices not allowed')
  23.    return
  24.  end
  25.  if bottype == 'syst'
  26.    botstates = botnum;
  27.    actbot = bot(1:botnum+botrows,1:botnum+botcols);
  28.  elseif bottype == 'cons'
  29.    botstates = 0;
  30.    actbot = bot;
  31.  else
  32.    error('VARYING matrices not allowed')
  33.    return
  34.  end
  35.  nrb = botstates + botrows;
  36.  ncb = botstates + botcols;
  37.  states = topstates+botstates;
  38.  orderrow = [botstates+1:nrb 1:botstates];
  39.  ordercol = [botstates+1:ncb 1:botstates];
  40.  rebot = actbot(orderrow,ordercol);
  41.  out = genlft(acttop,rebot,dim1,dim2);
  42.  [nro nco] = size(out);
  43.  orderrow = [1:topstates nro-botstates+1:nro topstates+1:nro-botstates];
  44.  ordercol = [1:topstates nco-botstates+1:nco topstates+1:nco-botstates];
  45.  out = out(orderrow,ordercol);
  46.  if states == nro | states == nco
  47. %  if ALL of the inputs and outputs are closed,
  48. %  return the closed loop "A" matrix as a CONSTANT matrix
  49.    sys = out;
  50.  else
  51.    sys = pck(out(1:states,1:states),out(1:states,states+1:nco),...
  52.              out(states+1:nro,1:states),out(states+1:nro,states+1:nco));
  53.  end
  54. %
  55. % Copyright MUSYN INC 1991,  All Rights Reserved
  56.