LTPDA_CPSD makes cross-spectral density estimates of the time-series objects. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DESCRIPTION: LTPDA_CPSD makes cross-spectral density estimates of the time-series objects in the input analysis objects. CPSDs are computed using MATLAB's cpsd (>> help cpsd). CALL: b = ltpda_cpsd(a1,a2,a3,...,pl) INPUTS: b - output analysis objects aN - input analysis objects (at least two) pl - input parameter list The function makes CPSD estimates between all input AOs. Therefore, if the input argument list contains N analysis objects, the output a will contain NxN CPSD estimates. The diagonal elements will be S_ai_ai and will be equivalent to the output of ltpda_pwelch(ai) If the last input argument is a parameter list (plist) it is used. The following parameters are recognised. PARAMETERS: 'Win' - a specwin window object [default: Kaiser -200dB psll] 'Olap' - segment percent overlap [default: taken from window function] 'Nfft' - number of samples in each fft [default: length of input data] 'Order' - order of segment detrending: -1 - no detrending 0 - subtract mean [default] 1 - subtract linear fit N - subtract fit of polynomial, order N VERSION: $Id: ltpda_cpsd.m,v 1.10 2008/03/30 23:33:26 mauro Exp $ HISTORY: 07-02-2007 M Hewitson Creation The following call returns a parameter list object that contains the default parameter values: >> pl = ltpda_cpsd('Params') The following call returns a string that contains the routine CVS version: >> ver = ltpda_cpsd('Version') The following call returns a string that contains the routine category: >> category = ltpda_cpsd('Category') %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0001 function varargout = ltpda_cpsd(varargin) 0002 % LTPDA_CPSD makes cross-spectral density estimates of the time-series objects. 0003 % 0004 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0005 % 0006 % DESCRIPTION: LTPDA_CPSD makes cross-spectral density estimates of the 0007 % time-series objects in the input analysis objects. CPSDs are computed 0008 % using MATLAB's cpsd (>> help cpsd). 0009 % 0010 % CALL: b = ltpda_cpsd(a1,a2,a3,...,pl) 0011 % 0012 % INPUTS: b - output analysis objects 0013 % aN - input analysis objects (at least two) 0014 % pl - input parameter list 0015 % 0016 % The function makes CPSD estimates between all input AOs. 0017 % Therefore, if the input argument list contains N analysis objects, the 0018 % output a will contain NxN CPSD estimates. 0019 % The diagonal elements will be S_ai_ai and will be equivalent to 0020 % the output of ltpda_pwelch(ai) 0021 % 0022 % If the last input argument is a parameter list (plist) it is used. The 0023 % following parameters are recognised. 0024 % 0025 % PARAMETERS: 'Win' - a specwin window object [default: Kaiser -200dB psll] 0026 % 'Olap' - segment percent overlap [default: taken from window function] 0027 % 'Nfft' - number of samples in each fft [default: length of input data] 0028 % 'Order' - order of segment detrending: 0029 % -1 - no detrending 0030 % 0 - subtract mean [default] 0031 % 1 - subtract linear fit 0032 % N - subtract fit of polynomial, order N 0033 % 0034 % VERSION: $Id: ltpda_cpsd.m,v 1.10 2008/03/30 23:33:26 mauro Exp $ 0035 % 0036 % HISTORY: 07-02-2007 M Hewitson 0037 % Creation 0038 % 0039 % The following call returns a parameter list object that contains the 0040 % default parameter values: 0041 % 0042 % >> pl = ltpda_cpsd('Params') 0043 % 0044 % The following call returns a string that contains the routine CVS version: 0045 % 0046 % >> ver = ltpda_cpsd('Version') 0047 % 0048 % The following call returns a string that contains the routine category: 0049 % 0050 % >> category = ltpda_cpsd('Category') 0051 % 0052 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0053 0054 % 'Debug' - debug level for terminal output (0-1) 0055 0056 ALGONAME = mfilename; 0057 VERSION = '$Id: ltpda_cpsd.m,v 1.10 2008/03/30 23:33:26 mauro Exp $'; 0058 CATEGORY = 'Signal Processing'; 0059 0060 0061 %% Check if this is a call for parameters, the CVS version string 0062 % or the function category 0063 if nargin == 1 && ischar(varargin{1}) 0064 in = char(varargin{1}); 0065 if strcmp(in, 'Params') 0066 varargout{1} = getDefaultPL(); 0067 return 0068 elseif strcmp(in, 'Version') 0069 varargout{1} = VERSION; 0070 return 0071 elseif strcmp(in, 'Category') 0072 varargout{1} = CATEGORY; 0073 return 0074 end 0075 end 0076 0077 % capture input variable names 0078 invars = {}; 0079 as = []; 0080 ps = []; 0081 for j=1:nargin 0082 invars = [invars cellstr(inputname(j))]; 0083 if isa(varargin{j}, 'ao') 0084 as = [as varargin{j}]; 0085 end 0086 if isa(varargin{j}, 'plist') 0087 ps = [ps varargin{j}]; 0088 end 0089 end 0090 0091 0092 % check plist 0093 if isempty(ps) 0094 pl = getDefaultPL(); 0095 else 0096 pl = combine(ps, getDefaultPL); 0097 end 0098 0099 varargout{1} = ltpda_xspec(as, pl, 'CPSD', ALGONAME, VERSION, invars); 0100 0101 0102 %-------------------------------------------------------------------------- 0103 % Get default params 0104 function plo = getDefaultPL() 0105 0106 disp('* creating default plist...'); 0107 0108 plo = plist('Nfft', -0.5, ... 0109 'Win', specwin('Kaiser', 1, 100), ... 0110 'Olap', -1, ... 0111 'Order', 0); 0112 0113 disp('* done.'); 0114 0115