Get the value from coloumn correspond to the another coloimn max element

1 回表示 (過去 30 日間)
Konstantin Shchukin
Konstantin Shchukin 2022 年 7 月 17 日
回答済み: Star Strider 2022 年 7 月 17 日
I have a matrix n x 2. In the first coloumn some value is maximal. How can I get a value from the second coloumn which corresponses to the max value from the first coloumn?

採用された回答

Star Strider
Star Strider 2022 年 7 月 17 日
Try this —
M = rand(10,2)
M = 10×2
0.4981 0.4601 0.5309 0.6751 0.5092 0.7711 0.8724 0.4981 0.8387 0.6402 0.4003 0.2339 0.6984 0.1510 0.7369 0.9120 0.5813 0.9445 0.4677 0.8357
[Col1Max,idx] = max(M(:,1))
Col1Max = 0.8724
idx = 4
Result = M(idx,2)
Result = 0.4981
.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

製品


リリース

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by