For matrices, sort(X) sorts each column of X in ascending order.
For N-D arrays, sort(X) sorts the along the first non-singleton dimension of X. When X is a cell array of strings, sort(X) sorts the strings in ASCII dictionary order.
对于一个矩阵X,[M,N]=sort(X)返回矩阵每一列排序后的结果及每个排序后元素在原矩阵中列的位置。
dist_measured =
0 1.0000 1.7321 2.0000 1.7321 1.0000 1.0000
0 0 1.0000 1.7321 2.0000 1.7321 1.0000
0 0 0 1.0000 1.7321 2.0000 1.0000
0 0 0 0 1.0000 1.7321 1.0000
0 0 0 0 0 1.0000 1.0000
0 0 0 0 0 0 0
[x y]=sort(dist_measured)
x =
0 0 0 0 0 0 0
0 0 0 0 0 1.0000 1.0000
0 0 0 0 1.0000 1.0000 1.0000
0 0 0 1.0000 1.7321 1.7321 1.0000
0 0 1.0000 1.7321 1.7321 1.7321 1.0000
0 1.0000 1.7321 2.0000 2.0000 2.0000 1.0000
y =
1 2 3 4 5 6 6
2 3 4 5 6 1 1
3 4 5 6 4 5 2
4 5 6 3 1 2 3
5 6 2 2 3 4 4
6 1 1 1 2 3 5
由此可见直接求最大点坐标不合适,(find函数只会返回某一个值得坐标)
因此可用如下方法[x,y]=sort(dist_measured(:)),该方法返回dist_measured矩阵的向量形式并且排序,这样可得出最大的前L个值及其在向量中的位置,经过转换可求得在原矩阵中的坐标