The minimum value of a matrix array and its index

4 views (last 30 days)
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

Accepted Answer

Setsuna Yuuki.
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
A = rand(5) %example 5x5 matrix
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)




Community Treasure Hunt

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

Start Hunting!

Translated by