Effacer les filtres
Effacer les filtres

line and column of the minimun element of a matrix

1 vue (au cours des 30 derniers jours)
Opariuc Andrei
Opariuc Andrei le 16 Jan 2021
Modifié(e) : Jan le 16 Jan 2021
how do i find the position (line and column of the minimun element of a matrix)
i have a matrix
m=
[5 1 -400;
-6 100 -6;
2 5 25];
how can i get matlab to give me the position of -400 ? line 1 column 3

Réponse acceptée

Jan
Jan le 16 Jan 2021
Modifié(e) : Jan le 16 Jan 2021
m = [5 1 -400; ...
-6 100 -6;
2 5 25];
[~, ind] = min(m(:));
[row, col] = ind2sub(size(m), ind)
Or:
[v, ind1] = min(m, [], 1); % Along 1st dimension
[~, col] = min(v, [], 2); % Along 2nd dimension
row = ind1(col)

Plus de réponses (0)

Catégories

En savoir plus sur Test and Measurement dans Help Center et File Exchange

Produits


Version

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by