How to find the indices of elements in an array?

1 visualizzazione (ultimi 30 giorni)
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.

Risposta accettata

KALYAN ACHARJYA
KALYAN ACHARJYA il 23 Feb 2021
Modificato: KALYAN ACHARJYA il 24 Feb 2021
[r,c]=find(matrix==min(matrix(:)))
#Added
Get the values
matrix(matrix==min(matrix(:)))

Più risposte (1)

KSSV
KSSV il 23 Feb 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 Commenti
KSSV
KSSV il 23 Feb 2021
Read about logical indexing.

Accedi per commentare.

Categorie

Scopri di più su Operators and Elementary Operations in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by