Borrar filtros
Borrar filtros

Finding 2nd minimum value in an array

31 visualizaciones (últimos 30 días)
Khawaja Asim
Khawaja Asim el 3 de Mayo de 2012
Comentada: Andrei Bobrov el 27 de Mzo. de 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???

Respuesta aceptada

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

Más respuestas (0)

Categorías

Más información sobre Matrices and Arrays en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by