The minimum value of a matrix array and its index
5 views (last 30 days)
Show older comments
MOHAMED ABDULAZIM
on 14 Nov 2020
Commented: MOHAMED ABDULAZIM
on 20 Nov 2020
Hello everybody,
I want to get a single minimum value of a matrix and know its index.What shold I do?
Thank you very much
0 Comments
Accepted Answer
Setsuna Yuuki.
on 14 Nov 2020
Edited: Setsuna Yuuki.
on 15 Nov 2020
A = rand(1,5); %example matrix
[mini,index] = min(A) %mini= minimum value, index = index of minimum value
or
A = rand(5) %example 5x5 matrix
[minRow,indexRow]=min(A)
[minCol,indexCol]=min(minRow)
index = [indexRow(indexCol) indexCol] %minimum value o 5x5 matrix (row index, column index)
A = rand(5)
[M,I] = min(A(:));
[I_row, I_col] = ind2sub(size(A),I);
index = [I_row I_col]
More Answers (0)
See Also
Categories
Find more on Matrix Indexing 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!