How to find the indices of elements in an array?
1 view (last 30 days)
Show older comments
Ramya Gutta
on 23 Feb 2021
Edited: KALYAN ACHARJYA
on 24 Feb 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.
0 Comments
Accepted Answer
KALYAN ACHARJYA
on 23 Feb 2021
Edited: KALYAN ACHARJYA
on 24 Feb 2021
[r,c]=find(matrix==min(matrix(:)))
#Added
Get the values
matrix(matrix==min(matrix(:)))
More Answers (1)
KSSV
on 23 Feb 2021
A = rand(100) ;
[val,idx] = min(A(:)) ;
[i,j] = ind2sub(size(A),idx) ;
val
A(i,j)
3 Comments
See Also
Categories
Find more on Operators and Elementary Operations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!