Home > chronux > spectral_analysis > helper > dpsschk.m

dpsschk

PURPOSE ^

Helper function to calculate tapers and, if precalculated tapers are supplied,

SYNOPSIS ^

function [tapers,eigs]=dpsschk(tapers,N,Fs)

DESCRIPTION ^

 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,Fs)
 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)
 eigs          (eigenvalues)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [tapers,eigs]=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,Fs)
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 %
0013 % N             (number of samples)
0014 % Fs            (sampling frequency - this is required for nomalization of
0015 %                                     tapers: we need tapers to be such
0016 %                                     that integral of the square of each taper equals 1
0017 %                                     dpss computes tapers such that the
0018 %                                     SUM of squares equals 1 - so we need
0019 %                                     to multiply the dpss computed tapers
0020 %                                     by sqrt(Fs) to get the right
0021 %                                     normalization)
0022 % Outputs:
0023 % tapers        (calculated or precalculated tapers)
0024 % eigs          (eigenvalues)
0025 if nargin < 3; error('Need all arguments'); end
0026 sz=size(tapers);
0027 if sz(1)==1 && sz(2)==2;
0028     [tapers,eigs]=dpss(N,tapers(1),tapers(2));
0029     tapers = tapers*sqrt(Fs);
0030 elseif N~=sz(1);
0031     error('seems to be an error in your dpss calculation; the number of time points is different from the length of the tapers');
0032 end;

Generated on Fri 28-Sep-2012 12:34:30 by m2html © 2005