收藏 分享(赏)

EOF的源程序 MATLAB.doc

上传人:HR专家 文档编号:11560176 上传时间:2020-06-24 格式:DOC 页数:6 大小:40KB
下载 相关 举报
EOF的源程序 MATLAB.doc_第1页
第1页 / 共6页
EOF的源程序 MATLAB.doc_第2页
第2页 / 共6页
EOF的源程序 MATLAB.doc_第3页
第3页 / 共6页
EOF的源程序 MATLAB.doc_第4页
第4页 / 共6页
EOF的源程序 MATLAB.doc_第5页
第5页 / 共6页
点击查看更多>>
资源描述

1、 mssa.rar EEOF.M function E,V,A,C=eeof(X, M, convert) % Syntax: E,V,A,C=eeof(X, M); E,V,A,C=eeof(X, M, 1); % This function performs an extended empirical orthogonal % function (EEOF) analysis of matrix X, for embedding dimension M. % Each of the L columns of X is a time series of length N. % % Retur

2、ns: E - eigenfunction matrix. (LM by LM) % V - vector containing variances (unnormalized eigenvalues). % A - matrix of principal components. % C - lag-covariance matrix. % % V is ordered from large to small: E and A are sorted accordingly. % % Note that X is assumed to be centered. To center the dat

3、a, use % the commands: % r,c=size(X); X=X-ones(r,1)*mean(X); before running EEOF. % If you also want to standardize the data, use: % X=X./(ones(r,1)*std(X);. % % If a third argument is supplied, the eigenfunctions/values will % be reordered into the same format as MSSA output - i. e. L blocks % of s

4、ize M rather than M blocks of size L. % % This function provides the same output, within numerically determined % limits, as MSSA methods using Broomhead-King type covariance estimation: % it is intended as a check on those functions. % % Note that this function is *extremely* computationally intens

5、ive % for large matrices and lags. For example, if X is 1000 by 1000, % and M = 5, EEOF will take about 10 hours on a Cray YMP! Inputting % a subset of the PCs of X rather than the full data matrix can % substantially reduce the computational load. % % Written by Eric Breitenberger. Version date 1/1

6、1/96 % Please send comments and suggestions to ericgi.alaska.edu % N,L=size(X); if M*L=N-M+1, disp(Warning: Covariance matrix may be ill-conditioned.), end % Create the extended matrix: T=zeros(N-M+1,M*L); for i=1:M T(:,L*(i-1)+1:L*i)=X(i:N-M+i,:); end % Compute the eigenvectors/values of the covari

7、ance matrix: C=(T*T)/(N-M+1); clear X E,V=eig(C); V=diag(V); A=T*E; % compute principal components if nargin=3 % Prepare MSSA-style output: % sort E,V,C, and A from M blocks of L to L blocks of M. ind=1:L:(M-1)*L+1; for i=1:L, index=index ind+i-1; end E=E(index,index); V=V(index); % sort the covaria

8、nce matrix and PCs: C=C(index,index); A=A(:,index); end % Sort eigenvalues/vectors/PCs in descending order: V,ind=sort(-V); V=-V; E=E(:,ind); A=A(:,ind); 窗体底端 mssa.rar EOF.Mfunction F,L,B=eof(X,n,s); % EOF calculates the empirical orthogonal functions % and amplitudes (principal components) of the d

9、ata matrix X. % Syntax: F,L,B=eof(X); F,L,B=eof(X,.9,norm); % % Input: X - data matrix. For a standard (S-mode) EOF analysis, % the columns of X are time series, while the rows % are spatial maps. The eigenfunctions in this case % will be spatial patterns, and the principal % components are time ser

10、ies. % n - number of eigenfunctions to return (optional). % If n is less than 1, it is interpreted as % a fractional variance (e. g. n=.9), and enough % eigenvectors are returned to account for n*100% % of the variance. The default is to return all EOFs. % s - Normalization option. If s=norm, then e

11、ach % column of X will be normalized (assigned % unit variance). If s is not specified, the % data are not normalized. % % Output: F - eigenfunction matrix (columns are eigenvectors). % L - vector of eigenvalues.(all eigenvalues are returned) % B - principal components matrix. % % Written by Eric Br

12、eitenberger. Version date 1/11/96 % Please send comments and suggestions to ericgi.alaska.edu % r,c=size(X); if cr, disp(Warning: Covariance matrix may be ill-conditioned.), end if nargin=1 n=c; s=none; elseif nargin=2 if isstr(n) s=n; n=c; else s=none; end end X=X-ones(r,1)*mean(X); % center the da

13、ta if s=norm X=X./(ones(r,1)*std(X); % normalize elseif s=none error(Improper normalization option. Please check inputs.) end S=X*X; % compute the covariance matrix F,L=eig(S); clear S % sort eigenvectors, eigenvalues L,i=sort(diag(-L); L=-L; F=F(:,i); % figure out how many eigenvectors to keep: if

14、n=var); n=i(1); end if cn, F=F(:,1:n); end % keep only first n eigenvectors B=X*F; % calculate principal components (first n) mssa.rar EOFCENT.Mfunction F,L,B=eofcent(X,n); % EOF calculates the empirical orthogonal functions % and amplitudes (principal components) of the data matrix X. % Syntax: F,

15、L,B=eof(X); F,L,B=eof(X,.9); % % Input: X - data matrix. For a standard (S-mode) EOF analysis, % the columns of X are time series, while the rows % are spatial maps. The eigenfunctions in this case % will be spatial patterns, and the principal % components are time series. % n - number of eigenfunct

16、ions to return (optional). % If n is less than 1, it is interpreted as % a fractional variance (e. g. n=.9), and enough % eigenvectors are returned to account for n*100% % of the variance. The default is to return all EOFs. % % Output: F - eigenfunction matrix (columns are eigenvectors). % L - vecto

17、r of eigenvalues.(all eigenvalues are returned) % B - principal components matrix. % % EOFCENT does the same thing as EOF, but does not allow the data matrix to % be modified within the function, thus avoiding the memory penalty of passing % the large data matrix into the function. If you want to ce

18、nter or % standardize the data, you must do it in the main workspace before calling % EOFCENT The commands r,c=size(X); X=X-ones(r,1)*mean(X); will center the % data. If you then want to standardize the data, use X=X./(ones(r,1)*std(X);. % % Written by Eric Breitenberger. Version date 1/11/96 % Plea

19、se send comments and suggestions to ericgi.alaska.edu % r,c=size(X); if cr, disp(Warning: Covariance matrix may be ill-conditioned.), end if nargin=1 n=c; end S=X*X; % compute the covariance matrix F,L=eig(S); clear S % sort eigenvectors, eigenvalues L,i=sort(diag(-L); L=-L; F=F(:,i); % figure out how many eigenvectors to keep: if n=var); n=i(1); end if cn, F=F(:,1:n); end % keep only first n eigenvectors B=X*F; % calculate principal components (first n) 窗体底端窗体底端

展开阅读全文
相关资源
猜你喜欢
相关搜索
资源标签

当前位置:首页 > 网络科技 > 计算机原理

本站链接:文库   一言   我酷   合作


客服QQ:2549714901微博号:道客多多官方知乎号:道客多多

经营许可证编号: 粤ICP备2021046453号世界地图

道客多多©版权所有2020-2025营业执照举报