如何选择矩阵列从最小的行值

3视图(30天)
我目前在做一个多部分的任务,但我最后一步涉及到排序矩阵生成找到最小值行并选择整个列:
例如:
distance_to_point = [2、3、4、5;6.8,2.9,6.1,6.7)
我需要选择的列第二行中的最小值(值)的距离,而且还确定点的距离来衡量,所以我最终;
new_point = [3;2.9)
我怎么做呢?

接受的答案

Sindar
Sindar 2020年8月18日
distance_to_point = [2、3、4、5;6.8,2.9,6.1,6.7)
[~,idx] = min (distance_to_point (2:));
new_point = distance_to_point (:, idx);

答案(1)

莎拉Boznik
莎拉Boznik 2020年8月18日
编辑:莎拉Boznik 2020年8月18日
distance_to_point = [2、3、4、5;6.8,2.9,6.1,6.7)
最小值= min (distance_to_point (2:))
[m, n] =找到(distance_to_point = =最小值)
r = distance_to_point (1, n)
new_point =[最小值;r]

下载188bet金宝搏


释放

R2018b

社区寻宝

找到宝藏在MATLAB中央,发现社区如何帮助你!

开始狩猎!