Finding 2nd minimum value in an array

조회 수: 10 (최근 30일)
Khawaja Asim
Khawaja Asim 2012년 5월 3일
댓글: Andrei Bobrov 2015년 3월 27일
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???

채택된 답변

Andrei Bobrov
Andrei Bobrov 2012년 5월 3일
A2 = sort(A(:));
out = A2(2);
other way:
A2 = unique(A(:));
out = A2(2);
or:
out = min(setdiff(A(:),min(A(:))));
etc.
  댓글 수: 1
Andrei Bobrov
Andrei Bobrov 2015년 3월 27일
the third minimum
A2 = unique(A(:));
out = A2(3);

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Dates and Time에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by