Watch this Author's files
I find a simple
sqrt((a-b)'*(a-b))
faster to compute the Euclidean distance
Thanks. using repmat has made it useful and fast.
Things can go wrong in extreme cases. If dimensionality is very high numerical errors will kick in.
I have twenty-five hundred 10'000 dimensional vectors stored in matrix X and
~ sum(diag(distance(X',X'))) = 6e-4; ~
Other than that, great job!
Why is the -2ab term included?
Contact us at files@mathworks.com