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

  1. % function yout = vfft(yin,n)
  2. %
  3. %  Perform an N length FFT on the VARYING matrix YIN.  N is optional,
  4. %  defaulting to the number of INDEPENDENT VARIABLEs in YIN.  If N is
  5. %  greater than the number of INDEPENDENT VARIABLEs in YIN, the data 
  6. %  is zero padded.  If N is less the data is truncated.  The MATLAB 
  7. %  function FFT is used for the actual calculation.
  8. %
  9. %  It is assumed that the YIN is a time scale in seconds and YOUT is
  10. %  returned with a frequency scale in radians/sec.  The time scale
  11. %  is assumed to be monotonic and only the first interval is used
  12. %  to determine the frequency scale.  
  13. %
  14. %   See also:  FFT, IFFT and  VIFFT.
  15.  
  16. function Y = vfft(y,n)
  17.  
  18. if nargin == 0,
  19.     disp('usage: Y = vfft(y,n)')
  20.     return
  21.     end
  22.     
  23. [type,nr,nc,npts] = minfo(y);
  24. if type == 'syst',
  25.     error('input is not VARYING or CONSTANT')
  26.     return
  27.     end
  28.  
  29. if type == 'cons',
  30.     Y = y;
  31.     return
  32.     end
  33.  
  34. if nargin == 1,
  35.     length = npts;
  36. elseif nargin == 2,
  37.     length = n;
  38. else
  39.     error('too many arguments')
  40.     return
  41.     end
  42.  
  43. [ydat,yptr,t] = vunpck(y);
  44. tinc = t(2) - t(1);
  45.  
  46. finc = 2*pi/(tinc*length);
  47. omega = [0:finc:finc*(length-1)];
  48.  
  49.  
  50. Y = [];
  51. for i = 1:nr,
  52.     Yrow = [];
  53.     for j = 1:nc
  54.         [ydata,yptr,t] = vunpck(sel(y,i,j));
  55.         sisoY = fft(ydata,length);
  56.         sisoY = vpck(sisoY,omega);
  57.         Yrow = sbs(Yrow,sisoY);
  58.         end
  59.     Y = abv(Y,Yrow);
  60.     end
  61. %
  62. % Copyright MUSYN INC 1991,  All Rights Reserved
  63.