your example code does not work. Bsxfun cannot operate on those arrays. When X (as in your case) is an Nx2 matrix, and you want to calculate the distance of every new point (no matter what distance) in
you need to permute it into a 1x2xM matrix, with M being the number of new points.
In the line to calculate the Chebyshev distance, you used the max command wrong, because what you need is the maximum of the distances in each dimension (as far as I understand the definition of that distance correctly). Have a look at
to see what i mean.
So this is what I came up with:
oldpoints = meas(:,3:4);
newpoints = [5 1.45; 7 2; 4 2.5; 2 3.5];
newpoints = permute(newpoints, [3,2,1]);
dists_euclid = sqrt(sum(bsxfun(@minus, newpoints, oldpoints).^2, 2));
dists_cheby = max(abs(bsxfun(@minus, oldpoints, newpoints)),,2);
after that you can use the command
to get a two dimensional array again (might be easier to handle) and do the sorting stuff.
Hope this helps!