How to find the indices of elements in an array?

1 回表示 (過去 30 日間)
Ramya Gutta
Ramya Gutta 2021 年 2 月 23 日
編集済み: KALYAN ACHARJYA 2021 年 2 月 24 日
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.

採用された回答

KALYAN ACHARJYA
KALYAN ACHARJYA 2021 年 2 月 23 日
編集済み: KALYAN ACHARJYA 2021 年 2 月 24 日
[r,c]=find(matrix==min(matrix(:)))
#Added
Get the values
matrix(matrix==min(matrix(:)))

その他の回答 (1 件)

KSSV
KSSV 2021 年 2 月 23 日
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 件のコメント
KSSV
KSSV 2021 年 2 月 23 日
Read about logical indexing.
Ramya Gutta
Ramya Gutta 2021 年 2 月 23 日
Okay. Thank you.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeOperators and Elementary Operations についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by