


Helper function to calculate tapers and, if precalculated tapers are supplied,
to check that they (the precalculated tapers) the same length in time as
the time series being studied. The length of the time series is specified
as the second input argument N. Thus if precalculated tapers have
dimensions [N1 K], we require that N1=N.
Usage: tapers=dpsschk(tapers,N)
Inputs:
tapers (tapers in the form of:
(i) precalculated tapers or,
(ii) [NW K] - time-bandwidth product, number of tapers)
N (number of samples)
Fs (sampling frequency - this is required for nomalization of
tapers: we need tapers to be such
that integral of the square of each taper equals 1
dpss computes tapers such that the
SUM of squares equals 1 - so we need
to multiply the dpss computed tapers
by sqrt(Fs) to get the right
normalization)
Outputs:
tapers (calculated or precalculated tapers)

0001 function tapers=dpsschk(tapers,N,Fs) 0002 % Helper function to calculate tapers and, if precalculated tapers are supplied, 0003 % to check that they (the precalculated tapers) the same length in time as 0004 % the time series being studied. The length of the time series is specified 0005 % as the second input argument N. Thus if precalculated tapers have 0006 % dimensions [N1 K], we require that N1=N. 0007 % Usage: tapers=dpsschk(tapers,N) 0008 % Inputs: 0009 % tapers (tapers in the form of: 0010 % (i) precalculated tapers or, 0011 % (ii) [NW K] - time-bandwidth product, number of tapers) 0012 % N (number of samples) 0013 % Fs (sampling frequency - this is required for nomalization of 0014 % tapers: we need tapers to be such 0015 % that integral of the square of each taper equals 1 0016 % dpss computes tapers such that the 0017 % SUM of squares equals 1 - so we need 0018 % to multiply the dpss computed tapers 0019 % by sqrt(Fs) to get the right 0020 % normalization) 0021 % Outputs: 0022 % tapers (calculated or precalculated tapers) 0023 if nargin < 2; error('Need all arguments'); end 0024 sz=size(tapers); 0025 if sz(1)==1 & sz(2)==2; 0026 tapers=dpss(N,tapers(1),tapers(2))*sqrt(Fs); 0027 elseif N~=sz(1); 0028 error('seems to be an error in your dpss calculation; the number of time points is different from the length of the tapers'); 0029 end;