maximum position of element in a matrix

10 visualizaciones (últimos 30 días)
Mate 2u
Mate 2u el 11 de Abr. de 2012
Hi I have a 1000x1000 matrix. I want to find the location and the value of the highest value in the matrix?

Respuesta aceptada

Richard Brown
Richard Brown el 11 de Abr. de 2012
Pretty straightforward - the only complicating factor is that max only works down one dimension at a time, so you either have to call it twice or turn the matrix temporarily into a vector. Probably easiest is this:
M = rand(1000);
[maxVal, idx] = max(M(:));
idx is a linear index. If you want the row/column index then
[i, j] = ind2sub(size(M), idx);

Más respuestas (1)

Thomas
Thomas el 11 de Abr. de 2012
[p,q,r]=find(A==max(max(a)))
Assuming ur matrix is A

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