Azzera filtri
Azzera filtri

Finding 2nd minimum value in an array

31 visualizzazioni (ultimi 30 giorni)
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???

Risposta accettata

Andrei Bobrov
Andrei Bobrov il 3 Mag 2012
A2 = sort(A(:));
out = A2(2);
other way:
A2 = unique(A(:));
out = A2(2);
or:
out = min(setdiff(A(:),min(A(:))));
etc.

Più risposte (0)

Categorie

Scopri di più su Matrices and Arrays in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by