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

1 view (last 30 days)
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?

Accepted Answer

Star Strider
Star Strider on 17 Jul 2022
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
.

More Answers (0)

Products


Release

R2022a

Community Treasure Hunt

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

Start Hunting!