function dist=distance(x,y);
%function dist=distance(x,y);
dist(1)=0;
dist(2:length(x))=cumsum(sqrt(diff(x).^2+diff(y).^2));
if size(dist)~=size(x)
         dist=remat(dist,x);
end