Find the largest element and its location in a 3 dimensional array

2 visualizaciones (últimos 30 días)
How to find the largest element and its location in case of a 3 dimensional array in Matlab?

Respuesta aceptada

Walter Roberson
Walter Roberson el 8 de Ag. de 2021
Editada: Walter Roberson el 8 de Ag. de 2021
[largest_value, idx] = max(YourArray, [], 'all', 'linear');
[row, col, page] = ind2sub(size(YourArray), idx);
In older releases you would probably use
[largest_value, idx] = max(YourArray(:));
[row, col, page] = ind2sub(size(YourArray), idx);
  2 comentarios
Israa Ahmed
Israa Ahmed el 8 de Ag. de 2021
Very Good.
Thank you very much. Both worked well for me.
Note: The second function is "ind2sub" not "ind2sum".
Walter Roberson
Walter Roberson el 8 de Ag. de 2021
Opps, my fingers typed ahead of my brain!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre MATLAB 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