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

  1. % function sys = fminter(magdata,weight,heading,osysl_g)
  2. %
  3. %  *****  UNTESTED  *****
  4. %
  5. %   FMINTER fits a stable, minimum phase transfer function
  6. %   to magnitude data, MAGDATA, with a supplied frequency
  7. %   domain weighting function, WEIGHT. Both these should
  8. %   be VARYING matrices, with identical INDEPENDENT
  9. %   VARIABLE values. FITMAG uses GENPHASE to generate
  10. %   phase data, and FITSYS to do the fit.  OSYSL_G (optional) 
  11. %   is the frsp of the old fit.  If given, it will be
  12. %   displayed along with the data.
  13. %   Identical to fitmag except that fitmaglp is used instead
  14. %   of genphase and fitsys.  
  15. %
  16. %   See also: FITSYS, GENPHASE, INVFREQS, MAGFIT, MUFTBTCH,
  17. %             MUSYNFLP and MUSYNFIT.
  18.  
  19. function sys = fminter(d,wt,heading,osysl_g)
  20.  
  21.  if nargin < 2
  22.    disp(['usage: sys = fitmag(magdata,weight)']);
  23.    return
  24.  end
  25.  if nargin == 2
  26.    heading = [];
  27.  end
  28.  
  29.  [dtype,drows,dcols,dnum] = minfo(d);
  30.  if dtype ~= 'vary'
  31.    error(['MAGDATA should be a VARYING matrix']);
  32.    return
  33.  end
  34.  
  35.  [wtype,wrows,wcols,wnum] = minfo(wt);
  36.  if wtype ~= 'vary'
  37.    error(['WEIGHT should be a VARYING matrix']);
  38.    return
  39.  end
  40.  
  41.  code = indvcmp(d,wt);
  42.  if code ~= 1
  43.     error('inconsistent VARYING data in MAGDATA and WEIGHT')
  44.     return
  45.  end
  46.  
  47. % vplot('liv,lm',d)    % replaced by the following code
  48.     clg;subplot(211);             % begin JCD CHANGE 
  49.      if nargin <= 3
  50.         vplot('liv,lm',d);
  51.          xlabel('  data ');
  52.       else
  53.         vplot('liv,lm',d,osysl_g);
  54.          xlabel('  data and old fit ');
  55.      end    
  56.     title([heading]);
  57.     subplot(212);
  58.     vplot('liv,lm',wt); 
  59.     title('wt for fit');              %  end JCD CHANGE
  60.  xlabel(['NOTE APPROXIMATE ORDER NECESSARY FOR FIT.....']);
  61.  ord = input('ENTER ORDER OF CURVE FIT      ');
  62.  while any([ isempty(ord)  (ord<0)  (floor(ord) ~= ceil(ord)) ])
  63.      ord = input('try again - a nonnegative integer..    ');
  64.  end
  65.  
  66.  
  67.  while ord >= 0
  68.    sysh = fitmaglp(d,[.26,.1,ord,ord],wt);
  69.    sysh_g = frsp(sysh,d);
  70.    rat_data = sbs(d,sysh_g);
  71.    hhead = [',   W/ORDER = ' int2str(ord)];
  72.  
  73. %   vplot('liv,lm',rat_data)  %  replaced by the following code
  74.     clg;subplot(211);             % begin JCD CHANGE
  75.      if nargin <= 3
  76.         vplot('liv,lm',sysh_g,resp);
  77.          xlabel('  1) fit    2) data ');
  78.       else
  79.         vplot('liv,lm',sysh_g,resp,osysl_g);
  80.          xlabel('  1) fit    2) data   3) oldfit ');
  81.      end
  82.     title([heading hhead]);
  83.     subplot(212);
  84.     vplot('liv,lm',wt); 
  85.     title('wt for fit');            % end JCD CHANGE
  86.  
  87.    xlabel('ENTER NEW ORDER, or NEGATIVE NUMBER TO STOP ');
  88.    pause;
  89.    ord = input('ENTER NEW ORDER, NEGATIVE TO STOP    ');
  90.    while any([ isempty(ord)  (floor(ord) ~= ceil(ord)) ])
  91.        ord = input('try again - an integer, negative to stop..    ');
  92.    end %while any
  93.  end %while ord
  94. sys = sysh;
  95. subplot;
  96. %
  97. % Copyright MUSYN INC 1991,  All Rights Reserved
  98.