dpsschk.m 1.7 KB

1234567891011121314151617181920212223242526272829303132
  1. function [tapers,eigs]=dpsschk(tapers,N,Fs)
  2. % Helper function to calculate tapers and, if precalculated tapers are supplied,
  3. % to check that they (the precalculated tapers) the same length in time as
  4. % the time series being studied. The length of the time series is specified
  5. % as the second input argument N. Thus if precalculated tapers have
  6. % dimensions [N1 K], we require that N1=N.
  7. % Usage: tapers=dpsschk(tapers,N,Fs)
  8. % Inputs:
  9. % tapers (tapers in the form of:
  10. % (i) precalculated tapers or,
  11. % (ii) [NW K] - time-bandwidth product, number of tapers)
  12. %
  13. % N (number of samples)
  14. % Fs (sampling frequency - this is required for nomalization of
  15. % tapers: we need tapers to be such
  16. % that integral of the square of each taper equals 1
  17. % dpss computes tapers such that the
  18. % SUM of squares equals 1 - so we need
  19. % to multiply the dpss computed tapers
  20. % by sqrt(Fs) to get the right
  21. % normalization)
  22. % Outputs:
  23. % tapers (calculated or precalculated tapers)
  24. % eigs (eigenvalues)
  25. if nargin < 3; error('Need all arguments'); end
  26. sz=size(tapers);
  27. if sz(1)==1 && sz(2)==2;
  28. [tapers,eigs]=dpss(N,tapers(1),tapers(2));
  29. tapers = tapers*sqrt(Fs);
  30. elseif N~=sz(1);
  31. error('seems to be an error in your dpss calculation; the number of time points is different from the length of the tapers');
  32. end;