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

  1. % function out = sisorat(freq,gain)
  2. %    or
  3. % function out = sisorat(data_g)
  4. %
  5. %   Finds a first order, stable transfer function that has a
  6. %   gain of GAIN at a frequency FREQ. In the case of one
  7. %   input argument, DATA_G must be a 1x1 VARYING matrix, with
  8. %   1 data point. The INDEPENDENT VARIABLE is interpreted as
  9. %   FREQ, and the value of the matrix is interpreted as GAIN.
  10. %   The transfer function produced has constant magnitude
  11. %   across frequencies.
  12. %
  13. %   See also: DYPERT, MU, RANDEL, UNWRAPP.
  14.  
  15. function out = sisorat(freq,gain)
  16.  if nargin < 1
  17.    disp('usage: out = sisorat(freq,gain)')
  18.    return
  19.  end
  20.  if nargin == 1
  21.    [ftype,frows,fcols,fnum] = minfo(freq);
  22.    sss = freq;
  23.    if ftype == 'vary'
  24.      if frows == 1 & fcols == 1 & fnum == 1
  25.        freq = sss(1,2);
  26.        gain = sss(1,1);
  27.      else
  28.        error('if input is varying, it should be 1pt, 1x1')
  29.        return
  30.      end
  31.    else
  32.      error('if only 1 input, it should be 1pt, 1x1')
  33.      return
  34.    end
  35.  end
  36.  if isempty(freq) | isempty(gain)
  37.    error('need non-empty frequency and gain')
  38.    out = [];
  39.    return
  40.  end
  41.  if freq < 0
  42.    error('need non-negative frequency')
  43.    out = [];
  44.    return
  45.  end
  46.  if freq == 0 & imag(gain) ~= 0
  47.    error('need nonzero frequency for complex gain')
  48.    return
  49.  end
  50.  if abs(gain) < 1e-13
  51.   disp('WARNING_IN_SISORAT: gain is zero')
  52.   out = 0.0;
  53.   return
  54.  end
  55.  disk = gain/abs(gain);
  56.  sw = 1;
  57.  if imag(disk) == 0
  58.    out = gain;
  59.  else
  60.    if imag(disk) < 0
  61.      sw = -1;
  62.      disk = -disk;
  63.    end
  64.    pscal = sqrt(abs(gain));
  65.    beta = (imag(disk)*freq)/(1+real(disk));
  66.    bc = sqrt(2*beta);
  67.    out = [-beta -pscal*bc 1 ; pscal*sw*bc pscal*pscal*sw 0 ; 0 0 -inf];
  68.  end
  69. %
  70. % Copyright MUSYN INC 1991,  All Rights Reserved
  71.