# Documentation of eof2

Global Index (all files) (short | long) | Local Index (files in subdir) (short | long)

## Function Synopsis

`[pc,eof_reg,sing]=eof2(input_array,n,nya)`

## Help text

``` function [pc,eof_reg,sing]=eof2(input_array,n,nya)

Computes the EOF of the input_array by formulating
the covariance matrix in time. PCs are normalized;
EOF's are regression maps upon the normalized PC's; SING
is the singular values.

INPUTS:
input_array
N : number of regression maps to compute
NYA is the latidue axis of the maps (from top to bottom)
```

## Cross-Reference Information

This function calls

## Listing of function eof2

```function [pc,eof_reg,sing]=eof2(input_array,n,nya)

[ts,gs]=size(input_array);

cov_matrix=nan*ones(ts,ts);

% lets make a covariance matrix in time
disp 'making cov matrix'
for i=1:ts
if (i/10)==round(i/10)
ts-i
end
% only go from i to the end of the matrix
for j=i:ts
cov_matrix(i,j)=cosp(input_array(i,:),input_array(j,:),...
nya,0);
cov_matrix(j,i)=cov_matrix(i,j);
end
end

[left_vec,sing,right_vec]=svd(cov_matrix,0);
sing=diag(sing);

for eof_nu=1:n
pc(eof_nu,:)=left_vec(:,eof_nu)';
pc(eof_nu,:)=pc(eof_nu,:)./std2(pc(eof_nu,:));
end

% reg
for eof_nu=1:n
eof_nu
tmp=pc(eof_nu,:)';
for grd=1:gs
eof_reg(eof_nu,grd)=cov5(input_array(:,grd),tmp);
end

end

```