X=reshape(X,1,1,[]);
Y=reshape(Y,1,1,[]);
xgrid=linspace(xmin,xmax,100);
ygrid=linspace(ymin,ymax,100);
delta = hypot( bsxfun(@minus,X,xgrid) , bsxfun(@minus,Y,ygrid));
No idea why you've applied repmat along the jj-axis. It just duplicates data with no apparent purpose. But, you can incorporate it with the above, if you like
delta= repmat(delta,100,1);