locating the relative position of a value in a 2 x matrix
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I have a 180 by 180 matrix and want to locate the position of the minimum value so I can subsequently reuse the source variables used in the creation of that matrix.
i.e. the minimum valur occurs at row 10 and column 130 but I have not been able to simply return those two numbers.
0 comentarios
Respuesta aceptada
Daniel Shub
el 22 de Mayo de 2012
x = randn(180);
[~, I] = min(x(:));
[I, J] = ind2sub(size(x), I);
0 comentarios
Más respuestas (3)
Daniel Shub
el 22 de Mayo de 2012
From an understanding point, maybe this is better
x = randn(180);
[y, I] = min(x);
[~, J] = min(y);
[I(J), J]
0 comentarios
Ver también
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!