Clear Filters
Clear Filters

The minimum value of a matrix array and its index

5 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
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)

Products


Release

R2013a

Community Treasure Hunt

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

Start Hunting!