


VECCOR1 computes the complex vector correlation. [a,theta]=VECCOR1(u1,v1,u2,v2) computes the complex vector correlation coefficient following Kundu (1976), JPO, 6, 238-242. Input are the four time series vectors. Output is complex, with amplitude and rotation angle in degrees. A positive angle indicates that series 1 is rotated positively (counterclockwise) from series 2. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ver. 1: 12/1/96 (RB) ver. 2: allow for complex arguments, remove mean %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


0001 function [a,theta]=veccor1(u1,v1,u2,v2) 0002 0003 % VECCOR1 computes the complex vector correlation. 0004 % 0005 % [a,theta]=VECCOR1(u1,v1,u2,v2) computes the complex vector correlation 0006 % coefficient following Kundu (1976), JPO, 6, 238-242. Input are the 0007 % four time series vectors. Output is complex, with amplitude and 0008 % rotation angle in degrees. A positive angle indicates that series 1 0009 % is rotated positively (counterclockwise) from series 2. 0010 % 0011 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0012 % ver. 1: 12/1/96 (RB) 0013 % ver. 2: allow for complex arguments, remove mean 0014 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0015 0016 % make input column vectors 0017 if(nargin==2), 0018 X=u1(:); 0019 Y=v1(:); 0020 else 0021 X=u1(:)+i*v1; 0022 Y=u2(:)+i*v2; 0023 end 0024 0025 % work on only the common good points 0026 ii=find((finite(X+Y))); 0027 % if no common good points, return NaNs 0028 if(length(ii)<1),amp=NaN;theta=NaN;trans=NaN;return;end 0029 X=X(ii); Y=Y(ii); 0030 0031 % remove mean 0032 X=X-mean(X(:)); Y=Y-mean(Y(:)); 0033 0034 % compute a, theta 0035 c=(rot90(X)*conj(Y))./(sqrt(rot90(X)*conj(X))*sqrt(rot90(Y)*conj(Y))); 0036 a=abs(c); 0037 theta=180.*angle(c)./pi; 0038