File Exchange

image thumbnail

Euclidean distance

version (1.15 KB) by wadzapi
Calculate euclidean distance


Updated 03 Jun 2013

View License

Calculate euclidean distance from every vector in matrix A to every in matrix B

Cite As

wadzapi (2021). Euclidean distance (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (3)

Florent Hennart


While Octave has "endfor", Matlab uses "end" for FOR loops.
BSXFUN ist faster than expanding the data by REPMAT.
SUM(Matrix, 2) replies a column vector, so I'd expect problems when you assign "dist_i" to a row of the result.
The missing pre-allocation slows down this function dramatically for larger inputs.

I think, this function cannot be used in its current state. Substantial changes in the code and a more detailed help section would be a a welcome improvement.

MATLAB Release Compatibility
Created with R2011b
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!