diff options
author | Rashpat93 | 2024-08-09 11:47:44 +0530 |
---|---|---|
committer | GitHub | 2024-08-09 11:47:44 +0530 |
commit | af6fe82f90dcb2314a3d37a9a1e297fb0fc447f3 (patch) | |
tree | 80effebb59b2042de6635493f4831ba215f19eee /macros/mscohere.sci | |
parent | b10cff2c07747b039e3c3ee83a34d437e958356b (diff) | |
parent | 2e21edde1c1a251a60739b15e1c699172401f044 (diff) | |
download | FOSSEE-Signal-Processing-Toolbox-master.tar.gz FOSSEE-Signal-Processing-Toolbox-master.tar.bz2 FOSSEE-Signal-Processing-Toolbox-master.zip |
Abinash's Work
Diffstat (limited to 'macros/mscohere.sci')
-rw-r--r-- | macros/mscohere.sci | 122 |
1 files changed, 41 insertions, 81 deletions
diff --git a/macros/mscohere.sci b/macros/mscohere.sci index 357da58..b9a45f8 100644 --- a/macros/mscohere.sci +++ b/macros/mscohere.sci @@ -1,82 +1,42 @@ -function [PXX, FREQ] = mscohere (X, Y, WINDOW, OVERLAP, NFFT, FS, RANGE) -//It estimate (mean square) coherence of signals x and y. -//Calling Sequence -//[Pxx, freq] = mscohere (x, y) -//[Pxx, freq] = mscohere (x, y, window) -//[Pxx, freq] = mscohere (x, y, window, overlap) -//[Pxx, freq] = mscohere (x, y, window, overlap, Nfft) -//[Pxx, freq] = mscohere (x, y, window, overlap, Nfft, Fs) -//[Pxx, freq] = mscohere (x, y, window, overlap, Nfft, Fs, range) -//mscohere (...) -//Description -//This function estimate (mean square) coherence of signals x and y. -//Examples -//[Pxx, freq] = mscohere(4,5) -//ans = -//PXX = -// Nan -// 1 -//FREQ = -// 0 -// 0.5 -funcprot(0); -lhs = argn(1) -rhs = argn(2) -if (rhs < 2 | rhs > 7) -error("Wrong number of input arguments.") -end - -select(rhs) - - case 2 then - if(lhs==0) - callOctave("mscohere",X,Y) - elseif(lhs==2) - [PXX, FREQ] = callOctave("mscohere",X,Y) - else - error("Wrong number of output arguments.") - end - - case 3 then - if(lhs==0) - callOctave("mscohere",X,Y,WINDOW) - elseif(lhs==2) - [PXX, FREQ] = callOctave("mscohere",X,Y,WINDOW) - else - error("Wrong number of output arguments.") - end - case 4 then - if(lhs==0) - callOctave("mscohere",X,Y,WINDOW,OVERLAP) - elseif(lhs==2) - [PXX, FREQ] = callOctave("mscohere",X,Y,WINDOW,OVERLAP) - else - error("Wrong number of output arguments.") - end - case 5 then - if(lhs==0) - callOctave("mscohere",X,Y,WINDOW,OVERLAP,NFFT) - elseif(lhs==2) - [PXX, FREQ] = callOctave("mscohere",X,Y,WINDOW,OVERLAP,NFFT) - else - error("Wrong number of output arguments.") - end - case 6 then - if(lhs==0) - callOctave("mscohere",X,Y,WINDOW,OVERLAP,NFFT,FS) - elseif(lhs==2) - [PXX, FREQ] = callOctave("mscohere",X,Y,WINDOW,OVERLAP,NFFT,FS) - else - error("Wrong number of output arguments.") - end - case 7 then - if(lhs==0) - callOctave("mscohere",X,Y,WINDOW,OVERLAP,NFFT,FS,RANGE,) - elseif(lhs==2) - [PXX, FREQ] = callOctave("mscohere",X,Y,WINDOW,OVERLAP,NFFT,FS,RANGE) - else - error("Wrong number of output arguments.") - end - end -endfunction +/*Description: +Estimate (mean square) coherence of signals x and y. Use the Welch (1967) periodogram/FFT method. +Calling Sequence: + [Pxx, freq] = mscohere (x, y) + […] = mscohere (x, y, window) + […] = mscohere (x, y, window, overlap) + […] = mscohere (x, y, window, overlap, Nfft) + […] = mscohere (x, y, window, overlap, Nfft, Fs) + […] = mscohere (x, y, window, overlap, Nfft, Fs, range) + mscohere (…) +See "help pwelch" for description of arguments, hints and references +Dependencies : pwelch +*/ +function varargout = mscohere(varargin) + // Check fixed argument + if (nargin < 2 || nargin > 7) + error("Invalid number of arguments"); + end + nvarargin = length(varargin); + // remove any pwelch RESULT args and add 'cross' + for iarg=1:nvarargin + arg = varargin(iarg); + if ( ~isempty(arg) && ( type(arg) == 10 ) && ( ~strcmp(arg,'power') || ... + ~strcmp(arg,'cross') || ~strcmp(arg,'trans') || ... + ~strcmp(arg,'coher') || ~strcmp(arg,'ypower') )) + varargin(iarg) = []; + end + end + varargin(nvarargin+1) = 'coher'; + disp(varargin) + if ( nargout==0 ) + pwelch(varargin(:)); + elseif ( nargout==1 ) + Pxx = pwelch(varargin(:)); + varargout(1) = Pxx; + elseif ( nargout>=2 ) + [Pxx,f] = pwelch(varargin(:)); + varargout(1) = Pxx; + varargout(2) = f; + end + endfunction |