Computes the distance 2-point correlation function of a finite 2D lattice. The functions is:
[ coorfun r rw] = twopointcorr(x,y,dr)
Where x is the list of x coordinates of lattice points. y is the list of y coordinates of the lattice points,and dr is the binning length for the correlation function. The outputs are coorfun, r, and rw. Coorfunis a vector of normalized correlation function values for distances recorded in the r vector. rw is the weight (number of points) contributing to corrfun calculation at a particular r. Low rw means that corrfun at that r value is unreliable.
This function has been fully vectorized to improve performance.