how to find array of second minimum value based on the index value
2 ビュー (過去 30 日間)
古いコメントを表示
index=[1 2 3 4 5];
p(i)=[0.1 0.2 0. 3 0.4 0.5];
based on the random position of p(i) second minimum value should occur not the index value
1 件のコメント
Azzi Abdelmalek
2016 年 5 月 6 日
What random position? "second minimum value should occur": what does that mean?
回答 (1 件)
Weird Rando
2016 年 5 月 6 日
編集済み: Weird Rando
2016 年 5 月 6 日
Unique function returns the vector in ascending order discarding any repetitive values. And the find function returns the index value.
p =[0.1 0.2 0.2 0.4 0.5];
a = unique(p);
find(p == a(2), 1,'first')
You can also find all the index value of the 2nd minimum value by replacing the find with
find(p == a(2))
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Creating and Concatenating Matrices についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!