Effacer les filtres
Effacer les filtres

Finding 2nd minimum value in an array

31 vues (au cours des 30 derniers jours)
Khawaja Asim
Khawaja Asim le 3 Mai 2012
Commenté : Andrei Bobrov le 27 Mar 2015
I want to find the 2nd minimum value in an array. min(A) can be used to find the minimum value, but I want to find the the number greater than minimum (2nd minimum). Can anyone help me in doing that???

Réponse acceptée

Andrei Bobrov
Andrei Bobrov le 3 Mai 2012
A2 = sort(A(:));
out = A2(2);
other way:
A2 = unique(A(:));
out = A2(2);
or:
out = min(setdiff(A(:),min(A(:))));
etc.
  1 commentaire
Andrei Bobrov
Andrei Bobrov le 27 Mar 2015
the third minimum
A2 = unique(A(:));
out = A2(3);

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Matrices and Arrays 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!

Translated by