function dlonglat = dlonglatdt(latlong, x, y, velx, vely)
% Calculate the rate of change of latitude and longitude based upon current
% latitude and longitude and the estimated deep-sea ocean currents

% Jon Yearsley & Julia Sigwart (Aug 2010)
% jon.yearsley@ucd.ie
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


xi = latlong(1);
yi = latlong(2);

if xi<min(x(1,:)) || xi>max(x(1,:)) || yi<min(y(:,1)) || yi>max(y(:,1))
    dlonglat = [0 0]';
else
    dlonglat = nan(2,1);
    dlonglat(1) = interp2(x,y,velx,xi,yi,'cubic');
    dlonglat(2) = interp2(x,y,vely,xi,yi,'cubic');
end
