COMCOR Complex correlation between two vector time series. [amp,theta,trans]=COMCOR(w1,w2) computes the complex vector correlation coefficient following Kundu (1976), JPO, 6, 238-242. Input: w1,w2 = complex column vectors representing currents or winds, etc, where w1=u1+i*v1, w2=u2+i*v2. Output: amp = amplitude of correlation. theta = rotation angle in degrees, where a positive angle indicates that series 1 is rotated positively (counterclockwise) from series 2. trans = transfer function. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Version 1.0: 12/4/96 Rich Signell (rsignell@usgs.gov) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

0001 function [amp,theta,trans]=comcor(w1,w2); 0002 0003 % COMCOR Complex correlation between two vector time series. 0004 % 0005 % [amp,theta,trans]=COMCOR(w1,w2) computes the complex vector correlation 0006 % coefficient following Kundu (1976), JPO, 6, 238-242. 0007 % 0008 % Input: w1,w2 = complex column vectors representing currents or winds, 0009 % etc, where w1=u1+i*v1, w2=u2+i*v2. 0010 % 0011 % Output: amp = amplitude of correlation. 0012 % theta = rotation angle in degrees, where a positive angle 0013 % indicates that series 1 is rotated positively 0014 % (counterclockwise) from series 2. 0015 % trans = transfer function. 0016 % 0017 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0018 % Version 1.0: 12/4/96 Rich Signell (rsignell@usgs.gov) 0019 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0020 0021 %columnize 0022 w1=w1(:); 0023 w2=w2(:); 0024 0025 % work on only the common good points 0026 ii=find((finite(w1+w2))); 0027 0028 % if no common good points, return NaNs 0029 if(length(ii)<1),amp=NaN;theta=NaN;trans=NaN;return;end 0030 0031 c=cov(w1(ii),w2(ii)); 0032 d=diag(c); 0033 x=c./sqrt(d*d'); 0034 amp=abs(x(2,1)); 0035 theta=angle(x(2,1))*180/pi; 0036 trans=abs(c(1,2)/c(1,1)); 0037

Generated on Wed 30-Nov-2005 14:45:02 by