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 日

7 投票

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 件)

カテゴリ

ヘルプ センター および File Exchange で Multidimensional Arrays についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by