Normalized distance between two points - MATLAB

时间:2016-05-17 11:04:36

标签: matlab normalization euclidean-distance

I would like to normalize the euclidean distance between two points so that it becomes between 0 & 1. The points are represented as follows: (x,y).

Any ideas?

1 个答案:

答案 0 :(得分:0)

这是一个解决方案,但是,我恳请您阅读我对您上述问题的评论。另外,请考虑@Adriaan的评论以供将来参考!

% First point
x1 = 5;
y1 = -2;

% Second point
x2 = 12;
y2 = 9;

% x and y differences
dx = abs(x1-x2);
dy = abs(y1-y2);

% Absolute distance between the points
dist = sqrt(dx^2 + dy^2);

% The normalization factor is now the distance
normFactor = dist;

将您的欧几里德空间中的所有内容与normFactor分开。如果你划分你的距离,你当然会得到距离= 1