欧式距离:
两点之间的直线距离:
- 二维平面上两点 a(x1,x2),b(y1,y2) 间的欧式距离为:
\(d = \sqrt{(x_{1}-y_{1})^{2}+(x_{2}-y_{2})^{2}}\)
- 三维平面上两点 a(x1,x2,x3), b(y1,y2,y3)间的欧氏距离:
\(d = \sqrt{(x_{1}-y_{1})^{2}+(x_{2}-y_{2})^{2}+(x_{3}-y_{3})^{2}}\)
- n维向量a(x1,x2,x3,.....,xn),b(y1,y2,y3,......,yn)间的欧式距离:
\(d = \sqrt{\sum_{i=1}^{n}\left ( x_{i}-y_{i}\right )^{2}} \)
- 向量表示法:\( \vec{a}\) 和 \(\vec{b}\) 间的欧式距离:
\(d = \sqrt{(\vec{a}-\vec{b})(\vec{a}-\vec{b})^{T}}\)
- Matlab计算(0,1),(1,1),(2,1)两两之间的欧式距离
曼哈顿距离(城市街区距离
):
两个点在标准坐标系上的绝对轴距总和:
- 二维平面上两点 a(x1,x2),b(y1,y2) 间的曼哈顿距离为:
\(d = \left | x_{1}-y_{1}\right |+\left | x_{1}-y_{2}\right |\)
- n维平面上两点 a(x1,x2,......,xn),b(y1,y2,......,yn) 间的曼哈顿距离为:
\(d = \sum_{i=1}^{n}\left | x_{i}-y_{i}\right |\)
- Matlab计算(0,1),(1,1),(2,1)两两之间的曼哈顿距离: