function [x,y,xm,ym,dx,dy,Nx,Ny]=modelsize(x,y)
%[x,y,xm,ym,dx,dy,Nx.Ny]=modelsize(x,y)
% makes values in x and y unique and sorted with correct orientation
% then compute the other values
% xm,ym cell center cordinates
% dx, dy cell widths (positivie)
% Nx, Ny size grid 
% TO 2004

% Copyright 2009 Theo Olsthoorn, TU-Delft and Waternet, without any warranty
% under free software foundation GNU license version 3 or later

x=unique(x(:)');
y=sort(unique(y(:)),'descend');
xm=0.5*(x(1:end-1)+x(2:end));
ym=0.5*(y(1:end-1)+y(2:end));
dx=diff(x);
dy=abs(diff(y));
Nx=length(dx);
Ny=length(dy);
M=ones(Ny,Nx);
