Suppose I have two matrices Nx2, Mx2 representing N, M 2d vectors respectively.Is there a simple and good way to calculate distances between each vector pair (n, m)?The easy but inefficient way is of course:d = zeros(N, M);for i = 1:N,  for j = 1:M,    d(i,j) = norm(n(i,:) - m(j,:));  endfor;endfor;The closest answer I've found is bsxfun, used like so:bsxfun(inline(x-y),[1,2,3,4],[3;4;5;6])ans =  -2 -1  0  1  -3 -2 -1  0  -4 -3 -2 -1  -5 -4 -3 -2
Octave: calculate distance between two matrices of vectors
performance;octave;vectorization