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

  1. % function [dsysl,dsysr] = musynfit(pre_dsysl,Ddata,sens,blk,nmeas,ncntrl,wt)
  2. %
  3. %   Fits the magnitude curve obtained by multiplying the old D 
  4. %   frequency response (from PRE_DSYSL) with the DDATA data. 
  5. %   Returns stable, minimum phase system matrices DSYSL and 
  6. %   DSYSR, which can be absorbed into the original interconnection 
  7. %   structure with multiplications (using MMULT), and one inverse 
  8. %   (using MINV). Once absorbed, a H_infinity design can be 
  9. %   performed, completing another iteration of MU-SYNTHESIS.
  10. %
  11. %   For the first MU-SYNTHESIS iteration, the variable
  12. %   PRE_DSYSL should be set to the string  'first'
  13. %   In subsequent iterations, PRE_DSYSL should be the previous
  14. %   (left) rational D-scaling system matrix, DSYSL.
  15. %
  16. %   See also: FITMAG, FITSYS, MAGFIT, and MUFTBTCH and MUSYNFLP.
  17.  
  18. function [dsysl,dsysr] = musynfit(osysl,magdata,sens,blk,nmeas,ncntrl,wt)
  19. if nargin < 6
  20.  disp('usage: [dsysl,dsysr] = musynfit(pre_dsysl,Ddata,sens,blk,nmeas,ncntrl)')
  21.  return
  22. end
  23. %
  24. [nblk,x] = size(blk);
  25. leftdim = nmeas;
  26.  for i=1:nblk
  27.   if blk(i,2) == 0
  28.     leftdim = leftdim + blk(i,1);
  29.     if blk(i,1) > 1
  30.       disp('full Ds not implemented yet')
  31.       return
  32.     end
  33.   else
  34.     leftdim = leftdim + blk(i,2);
  35.   end
  36.  end
  37. %
  38.  [mtype,mrows,mcols,mnum] = minfo(magdata);
  39.  omega = magdata(1:mnum,mcols+1);
  40.  [stype,srows,scols,snum] = minfo(sens);
  41.  if mnum ~= snum
  42.    error('SENS & MAG data have diff # of points - rerun VMU')
  43.    return
  44.  end
  45.  if nargin == 7
  46.    [wtype,wrows,wcols,wnum] = minfo(wt);
  47.    if wnum ~= mnum
  48.     error('WT & MAG data have diff # of points - rerun VMU')
  49.     return
  50.    end
  51.    supwt = wt(1:mnum,1);
  52.  else
  53.    supwt = ones(mnum,1);
  54.  end
  55. %
  56. %  NORMALIZE THE DATA BY THE LAST DSCALE
  57. %
  58.  magdata(1:mnum,1:mcols-1) = ...
  59.     inv(diag(magdata(1:mnum,mcols)))*magdata(1:mnum,1:mcols-1);
  60. %
  61. % MODIFICATION START %%%%%%%%%%%%%%
  62.  if isstr(osysl)
  63.    if strcmp(osysl,'first');
  64.      osysl_g = eye(leftdim);
  65.    else
  66.      error('First argument should be the string   first   or a SYSTEM matrix')
  67.      return  
  68.    end       
  69.  else        
  70.    [dum1,dum2,dum3,dum4] = minfo(osysl);
  71.    if strcmp(dum1,'syst')
  72.      osysl_g = frsp(osysl,omega);
  73.    elseif strcmp(dum1,'cons')
  74.      osysl_g = osysl;
  75.    else      
  76.      error('First argument should be the string   first   or a SYSTEM matrix')
  77.      return  
  78.    end       
  79.  end         
  80. % MODIFICATION END %%%%%%%%%%%%%%
  81.  loc = 1;
  82.  dsysl = [];
  83.  dsysr = [];
  84.  for i=1:nblk-1
  85.    wt = vpck((abs(sens(1:mnum,i) .* supwt)),omega);
  86.    osysl_g_loc = sel(osysl_g,loc,loc);
  87.    newdata = vabs(mmult(osysl_g_loc,sel(magdata,1,i)));
  88.    heading = ['FITTING D SCALING #' int2str(i)];
  89.    scalard = fitmag(newdata,wt,heading,osysl_g_loc);
  90.    tmpsys = [];
  91.    for j=1:min([blk(i,1) blk(i,2)])
  92.      tmpsys = daug(tmpsys,scalard);
  93.    end
  94.    dsysl = daug(dsysl,tmpsys);
  95.    dsysr = daug(dsysr,tmpsys);
  96.    if blk(i,1) < blk(i,2)
  97.      for j=1:(blk(i,2)-blk(i,1))
  98.        dsysl = daug(dsysl,scalard);
  99.      end
  100.    elseif blk(i,2) < blk(i,1)
  101.      for j=1:(blk(i,1)-blk(i,2))
  102.        dsysr = daug(dsysr,scalard);
  103.      end
  104.    end
  105.    loc = loc + blk(i,2);
  106.  end
  107.  dsysl = daug(dsysl,eye(blk(nblk,2)+nmeas));
  108.  dsysr = daug(dsysr,eye(blk(nblk,1)+ncntrl));
  109. %
  110. % Copyright MUSYN INC 1991,  All Rights Reserved
  111.