The minimum value of a matrix array and its index
5 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
MOHAMED ABDULAZIM
le 14 Nov 2020
Commenté : MOHAMED ABDULAZIM
le 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 commentaires
Réponse acceptée
Setsuna Yuuki.
le 14 Nov 2020
Modifié(e) : Setsuna Yuuki.
le 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]
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Matrix Indexing dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!