-
Notifications
You must be signed in to change notification settings - Fork 6
/
eofrotation.m
53 lines (47 loc) · 1.47 KB
/
eofrotation.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
function[rotModes, rotEigvals, rotExpVar, rotSignals, scaledRotSignals] = eofrotation(modes, eigvals, A, rotType, expVar)
%% Performs the EOF rotation and calculates associated values.
%
% [rotModes, rotEigvals, rotExpVar, rotSignals, scaledRotSignals] = eofrotation(modes, eigvals, A, rotType)
%
%
% ----- Inputs -----
%
% modes: The modes from an eof analysis that should be rotated.
%
% eigvals: The eigenvalues corresponding to the rotating modes.
%
% A: The analysis matrix used to generate the rotating modes.
%
% rotType: A string flag for the type of rotation
% 'varimax': Varimax Rotation
% 'equamax': Equamax Rotation
%
%
% ----- Outputs -----
%
% rotModes: The rotated eof modes.
%
% rotEigvals: The eigenvalues for the rotated modes.
%
% rotExpVar: The variance explained by the rotated modes.
%
% rotSignals: The signals corresponding to the rotated modes.
%
% scaledRotSignals: The signals corresponding to the rotated modes scaled
% to the analysis matrix.
%
%
% ----- Author -----
%
% Jonathan King, 2017, University of Arizona, [email protected]
% Do the rotation
[rotModes, rotMatrix] = rotatefactors( modes, 'method', rotType );
% Get the rotated eigenvalues
rotEigvals = diag( diag(eigvals) * rotMatrix );
% Get the explained variance of each rotated mode
rotExpVar = (rotEigvals / sum(rotEigvals)) * sum(expVar);
% Get the rotated signals
rotSignals = A * rotModes;
% Get the scaled, rotated signals
scaledRotSignals = scaleSignals( rotSignals, rotEigvals );
end