pdist2 equivalent in MATLAB version 7
Here is vectorized implementation for computing the euclidean distance that is much faster than what you have (even significantly faster than PDIST2 on my machine): D = sqrt( bsxfun(@plus,sum(A.^2,2),sum(B.^2,2)’) – 2*(A*B’) ); It is based on the fact that: ||u-v||^2 = ||u||^2 + ||v||^2 – 2*u.v Consider below a crude comparison between the two methods: … Read more