Calculate euclidean distance from every vector in matrix A to every in matrix B
John D'Errico's ipdm does this much better:
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.
Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.