% Enter your sea surface data as sst as a vector of idencical lentht to your time t vector. 
load sataltim_globalgrid;
% interval of your data (in days ) 
%dt = 9.91563 og flere siffre som du henter på nettet
%time = [0:368]*dt -5 ;  % construct time array number of obs 
% convert your time to decimal year and devide by 2pi to get year in radians. 
% Have to exclude last month which is wrong
grid2=grids(:,:,1:229);
%centring time around 2005; 
time = year-2005+(month-0.5)/12.0;
time = time(1:229);
t1 = time;
t0 = t1*0 + 1;
t2 = t1*2*pi;
t3 = t1.*t1;
t2 = t2;
d=grid2(:,:,1:5)*0.0;
for i=1:90
i
for j=1:120

% if you want to remove outliers (like data larger than 900)
sst2 = grid2(i,j,:).*(grid2(i,j,:)<900);
sst2=squeeze(sst2);
f = [t0 t1 0.5*t3 cos(t2) sin(t2)];
d(i,j,:) = f\sst2; 
     
end
end
%plot velocity
figure(1)
imagesc(d(:,:,2))
hold on
colorbar
%plot acceleration 
figure(3)
imagesc(d(:,:,3))
hold on
colorbar
