source: issm/trunk-jpl/externalpackages/pcatool/install/calsvd2.m@ 21589

Last change on this file since 21589 was 21589, checked in by Eric.Larour, 8 years ago

CHG: new pcatool for EOF analysis.

File size: 1.2 KB
Line 
1% [SVD1,SVD2,PC1,PC2,EXPVAR,Lambda] = CALSVD2(A,B,N) Compute SVDs
2%
3% Ref: H. Bjornson and S.A. Venegas: "A manual for EOF and SVD -
4% Analyses of climatic Data" 1997
5%================================================================
6%
7% Guillaume MAZE - LPO/LMD - March 2004
8% gmaze@univ-brest.fr
9
10
11 function [e1,e2,pc1,pc2,expvar,Lambda,dsumCF] = calsvd2(A,B,N);
12
13
14%================================================================
15% Ref: H. Bjornson and S.A. Venegas: "A manual for EOF and SVD -
16% Analyses of climatic Data" 1997 => p18
17
18% Assume that A is (time*map) matrix
19[n p]=size(A);
20
21% Remove the mean of each column (ie the time mean in each station records)
22S=detrend(A,'constant');
23P=detrend(B,'constant');
24
25% Form the covariance matrix:
26C=S'*P;
27
28% Find eigenvectors and singular values
29[U,Lambda,V] = svds(C,N);
30
31% PC
32a=S*U;
33b=P*V;
34
35% Make them clear for output
36for iN=1:N
37 e1(iN,:) = squeeze( U(:,iN) )';
38 pc1(iN,:) = squeeze( a(:,iN) )';
39 e2(iN,:) = squeeze( V(:,iN) )';
40 pc2(iN,:) = squeeze( b(:,iN) )';
41end
42
43% Amount of variance explained a 0.1 pres et en %
44L2=Lambda.^2;
45dsum=diag(L2)/trace(L2);
46for iN=1:N
47 expvar(iN)=fix( ( dsum(iN)*100/sum(dsum) )*10 ) /10;
48end
49
Note: See TracBrowser for help on using the repository browser.