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

1 次查看(过去 30 天)
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 CenterFile Exchange 中查找有关 MATLAB 的更多信息

产品


版本

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by