I have a 4 column matrix. I want to find the value corresponding to the minimum value of column 2. How to find it?

1 回表示 (過去 30 日間)
I have a matrix, A
A=[1 2.4 3.4 5;2 -0.2 3 4;3 8.1 3.2 4;4 0.5 5 2]
I want to find the value in column 1 corresponding to the minimum value of column 2. For example, for this case, the minimum value of column 2 would be -0.2 and the value corresponding to that in column 1 is 2. How to get to this value? I tried this:
min(A(:,2),1)
But I am not getting the desired result. Can anyone help me with it?

採用された回答

Abhishek Chakraborty
Abhishek Chakraborty 2021 年 10 月 29 日
A=[1 2.4 3.4 5;2 -0.2 3 4;3 8.1 3.2 4;4 0.5 5 2];
[minvalue,index]=min(A(:,2));
A(index,1)
ans =
2

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMatrices and Arrays についてさらに検索

製品


リリース

R2020b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by