


EOF Empirical orthogonal functions. [v,d,z]=eof(u) time series components stored as column vectors in u. v is the matrix of eigenvectors d is a diagonal matrix of eigenvalues z is the time series of mode amplitudes, stored as column vectors Reference: "Wallace and Dickinson, 1972, Journal of Applied Meteorology, V 11, N 6, p 887-892. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Version 1.0 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Version 2.0 modified by DAF 1/10/96 to account for bug in eig + add comments corrected 11/23/98 to account for complex eofs where Z=u*conj(v)


0001 function [v,d,z]=eof(u) 0002 %EOF Empirical orthogonal functions. 0003 % [v,d,z]=eof(u) 0004 % time series components stored as column vectors in u. 0005 % v is the matrix of eigenvectors 0006 % d is a diagonal matrix of eigenvalues 0007 % z is the time series of mode amplitudes, stored as column vectors 0008 % 0009 % Reference: "Wallace and Dickinson, 1972, Journal of Applied 0010 % Meteorology, V 11, N 6, p 887-892. 0011 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0012 % Version 1.0 0013 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0014 % Version 2.0 modified by DAF 1/10/96 to account for bug in eig + add comments 0015 % corrected 11/23/98 to account for complex eofs where Z=u*conj(v) 0016 % 0017 u=denan(u); %get rid of rows with missing data 0018 cc=cov(u); 0019 [v,d]=eig(cc,'nobalance'); 0020 d=diag(d,0); 0021 % 0022 % now we need to sort just in case eig did not 0023 % 0024 [newd,ord]=sort(d); 0025 newv=v(:,[ord]); 0026 if mean(newv(:,1)-v(:,1))~=0 0027 d=newd; 0028 v=newv; 0029 disp('vectors resorted'); 0030 end 0031 if abs(d(1))<abs(d(length(d))) % swap things into decending order 0032 d=d(length(d):-1:1); 0033 v=v(:,length(d):-1:1); 0034 end 0035 0036 z=u*conj(v); % accounts for complex matrices u 0037