Filter löschen
Filter löschen

Finding 2nd minimum value in an array

31 Ansichten (letzte 30 Tage)
Khawaja Asim
Khawaja Asim am 3 Mai 2012
Kommentiert: Andrei Bobrov am 27 Mär. 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???

Akzeptierte Antwort

Andrei Bobrov
Andrei Bobrov am 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.

Weitere Antworten (0)

Kategorien

Mehr zu Matrices and Arrays finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by