# Documentation of complex_eof

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

## Function Synopsis

`[lamda, loadings, pcs, per] = ceof(data, nkp);`

## Help text

```
Complex (Hilbert) EOF:

Outputs:
lamda    = eigenvalues (should be pretty close to real)
pcs      = First 10 Complex Principal Components (column dim)
per      = percent variance explained (real)

Inputs:
data     = data, so that size(data) = [ntime nspace]
nkp      = number of modes to output (default = 10);

Note:  pcs can be found by performing the following:

Normalization is such that:
pcs' * pcs = diag(lamda);

For display purposes, the following patterns and time
series go together:

Also, one can divide the pcs by sqrt(lamda) and multiply the
loadings by sqrt(lamda) to get actual amplitudes.  Recall,
std(real(pcs)) should equal std(imag(pcs)).

```

## Listing of function complex_eof

```function [lamda, loadings, pcs, per] = ceof(data, nkp);

%  a = 0.1:.1:10;
%  for i = 0:199
%    data((i+1),:) = sin(pi*(0.5*a + 0.1*i)) + 5*(rand(1,100)-0.5);
%  end
%  data = (data - ones(200,1)*mean(data));

if nargin < 2; nkp = 10; end;
if nargin < 1; error('Need to input data'); end;

[ntim, npt] = size(data);

disp('Calculating hilbert matrix')
%data = data + j * hilbert(data);
data = hilbert(data);
disp('Done with hilbert matrix, calculating covariance matrix')
c = data' * data / ntim;

disp('Covariance matrix computed, starting eig(c)')