%read array of sst data with year and 12 monthly values
% values are in hundredths of C
% missing values are -999
% for more info see "Cold Tongue Index" at http://jisao.washington.edu/data_sets/cti/
close all;
clear all;
load SST.dat;

%determine number of years of data
[ny,nm] = size(SST(:,1));

%load 2d array for processing into first column
for j=1:12
for i=1:ny
ic = (i-1)*12+j;
time(ic)=SST(i,1)+(j-1)/12.;
val(ic,1)=SST(i,j+1)*.01;
end
end

%deal with missing data crudely; set to 0
ind = find(val(:,1)==-9.99);
val(ind,1)=0;

%read array of soi data with year and 12 monthly values
%for further info see http://www.cru.uea.ac.uk/cru/data/soi.htm
%values are in tenths mb
load SOI.dat;

%load 2d array for processing
for j=1:12
for i=1:ny
ic = (i-1)*12+j;
val(ic,2)=SOI(i,j+1);
end
end
figure(1)
plot(val(:,1),'r');
figure(2)
plot(val(:,2),'b');

r = corr(val);
p = anova1(val);
polytool(val(:,1),val(:,2),1,.01)
pause
polytool(val(:,1),val(:,2),1,.05)
pause
