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,2307开发者_StackOverflow中文版6923076923 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));
精彩评论