returning Position in Array or Matrices for max()

8 visualizaciones (últimos 30 días)
Matthias
Matthias el 1 de Feb. de 2012
Hello
I'm wondering if there is a trick which can give you back the position (which row and which column) in matrices in which the max value is. max() only gives you the value.
thanks for your help.
Matthias

Respuesta aceptada

Walter Roberson
Walter Roberson el 1 de Feb. de 2012
[maxval, maxidx] = max(YourMatrix(:));
[row, col] = ind2sub(size(YourMatrix), maxidx);

Más respuestas (1)

Jan
Jan el 1 de Feb. de 2012
No, max() doe give you more than just the value. See:
help max
doc max
Looking in the documentation is a good idea - always.

Categorías

Más información sobre Creating and Concatenating Matrices en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by