1 %% Copyright (C) 2006 Peter V. Lanspeary <pvl@mecheng.adelaide.edu.au>
3 %% This program is free software; you can redistribute it and/or modify it under
4 %% the terms of the GNU General Public License as published by the Free Software
5 %% Foundation; either version 3 of the License, or (at your option) any later
8 %% This program is distributed in the hope that it will be useful, but WITHOUT
9 %% ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 %% FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
13 %% You should have received a copy of the GNU General Public License along with
14 %% this program; if not, see <http://www.gnu.org/licenses/>.
17 %% [Pxx,freq] = cpsd(x,y,Nfft,Fs,window,overlap,range,plot_type,detrend)
19 %% Estimate cross power spectrum of data "x" and "y" by the Welch (1967)
20 %% periodogram/FFT method.
21 %% See "help pwelch" for description of arguments, hints and references
23 function [varargout] = cpsd(varargin)
25 %% Check fixed argument
27 error( 'cpsd: Need at least 2 args. Use help cpsd.' );
29 nvarargin = length(varargin);
30 %% remove any pwelch RESULT args and add 'cross'
33 if ( ~isempty(arg) && ischar(arg) && ( strcmp(arg,'power') || ...
34 strcmp(arg,'cross') || strcmp(arg,'trans') || ...
35 strcmp(arg,'coher') || strcmp(arg,'ypower') ))
39 varargin{nvarargin+1} = 'cross';
44 Pxx = pwelch(varargin{:});
47 [Pxx,f] = pwelch(varargin{:});