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

1 visualización (últimos 30 días)
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?

Respuesta aceptada

Star Strider
Star Strider el 17 de Jul. de 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
.

Más respuestas (0)

Categorías

Más información sobre Logical en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by