简体   繁体   English

Matlab查找矩阵最小行

[英]Matlab finding matrix minimum row

I have matrix A with size Nx4, and I wanna find minimum pair in 2 and 4-th colomns in this matrix and get the number of this row, how can I do this? 我的矩阵A的大小为Nx4,我想在此矩阵的第2个列和第4个列中找到最小对,然后获取该行的编号,该怎么办?

for example: 例如:

200000  1,23076923076923    20  1,41538461538462
200000  1,23076923076923    200 1,32307692307692
200000  1,23076923076923    2000    1,32307692307692
200000  1,23076923076923    20000   1,29230769230769
200000  1,23076923076923    200000  1,41538461538462

I need something like this min(A(:, 2), A(:, 4)); 我需要这样的东西min(A(:, 2), A(:, 4));

answer will be 4th row. 答案将是第4行。

What is the "minimum pair"? 什么是“最小对”?

If it's the pair where both the second and the fourth column are at their lowest, the answer is 如果是第二列和第四列都处于最低点的那对,答案是

minimumRow = find(A(:,2)==min(A(:,2)) & A(:,4) == min(A(:,4)));

If it's the pair with the smallest sum, the answer is 如果是总和最小的那对,答案是

[~,minimumRow] = min(sum(A(:,[2 4]),2));

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM