How to find the indices of elements in an array?

1 visualización (últimos 30 días)
Ramya Gutta
Ramya Gutta el 23 de Feb. de 2021
Editada: KALYAN ACHARJYA el 24 de Feb. de 2021
I have a 103x103 array of values, in which i have to take the smallest values and get the respective (i,j) indices of those values. Can someone help me out with this problem.

Respuesta aceptada

KALYAN ACHARJYA
KALYAN ACHARJYA el 23 de Feb. de 2021
Editada: KALYAN ACHARJYA el 24 de Feb. de 2021
[r,c]=find(matrix==min(matrix(:)))
#Added
Get the values
matrix(matrix==min(matrix(:)))

Más respuestas (1)

KSSV
KSSV el 23 de Feb. de 2021
A = rand(100) ;
[val,idx] = min(A(:)) ;
[i,j] = ind2sub(size(A),idx) ;
val
val = 2.7946e-05
A(i,j)
ans = 2.7946e-05
  3 comentarios
KSSV
KSSV el 23 de Feb. de 2021
Read about logical indexing.
Ramya Gutta
Ramya Gutta el 23 de Feb. de 2021
Okay. Thank you.

Iniciar sesión para comentar.

Categorías

Más información sobre Operators and Elementary Operations 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