Borrar filtros
Borrar filtros

Extracting a value from one column to its corresponding column?

2 visualizaciones (últimos 30 días)
Yasir Ali
Yasir Ali el 15 de Dic. de 2016
Editada: Stephen23 el 15 de Dic. de 2016
Hi, I have a matrix (say 7 x 2). first column contains id and second column contains scores. I want to write a code to extract id from first column which is corresponding to minimum score in second column?
M = 1 363.026
11 330.302
24 289.07
55 240.3120
59 188.209
79 162.937
87 108.104
I know 87 has lowest score. But how to write effective code so that for larger matrix it should fetch id corresponding to lowest score? Thanks

Respuesta aceptada

KSSV
KSSV el 15 de Dic. de 2016
Editada: KSSV el 15 de Dic. de 2016
[val,idx] = min(M(:,2)) ; % get minimum value and position from scores
id = M(idx,1) ; % get the id of the minimum score
  1 comentario
Yasir Ali
Yasir Ali el 15 de Dic. de 2016
Thank you so much for this helpful answer. Worked fine. Really appreciated.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

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

Community Treasure Hunt

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

Start Hunting!

Translated by