function out=Divy(A,lat)
c=size(A);
N=c(1,2);
NN=c(1,1);


if nargin<2; error('Error - Not enough input parameters specified'), end;
if nargin>2; error('Error - too many input parameters specified'), end;
if length(lat)>NN;error('Error - vector of domain values has too large of dimensions'),end;
if length(lat)<NN;error('Error - vector of domain values has too small of dimensions'),end;
if (max(lat)-min(lat))>pi; error('ERROR- latitude nput should be in radians'), end;

out=zeros(NN,N);

a=6.37*10^6;

for m=1:1:N
    out(1,m)= (A(2,m)-A(1,m))/((lat(2)-lat(1)));
    out(NN,m)= (A(NN,m)-A(NN-1,m))/((lat(NN)-lat(NN-1)));
end
    
for m=2:1:NN-1
    for n=1:1:N
        out(m,n)=((A(m+1,n))-A(m-1,n))/((lat(m+1)-lat(m-1)));
    end
end
    
out=out/(a);
    



    
    