简体   繁体   中英

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?

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));

answer will be 4th row.

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));

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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