argmin of a vector
164 ビュー (過去 30 日間)
古いコメントを表示
Hello,
How can I pick up the argmin of a vector? I.e. In a vector such as a=[2 3 1 4 5], I want to pick up 1 by min(a) and also want to have 3 that is the Nth element of this vector with the minimum 1. I tried to use find(a=min(a)) but the find operator is not working with equality.
Thanks
0 件のコメント
採用された回答
James Tursa
2012 年 2 月 17 日
From the documentation for the min function:
[C,I] = min(...) finds the indices of the minimum values of A, and returns them in output vector I. If there are several identical minimum values, the index of the first one found is returned.
0 件のコメント
その他の回答 (2 件)
Walter Roberson
2012 年 2 月 17 日
If find is not working with equality then your values are probably not what you think they are:
0 件のコメント
Heather Jones
2018 年 8 月 5 日
The expression find(a=min(a)) is not valid. Try using == (which is used when testing equality) instead of = (which sets the left hand side equal to the right). find(a==min(a)) should work.
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で NaNs についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!