argmin of a vector
조회 수: 205 (최근 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!