Argmin with several minimums

조회 수: 5 (최근 30일)
Martin
Martin 2013년 6월 25일
Hi,
I would like to find a function returning, given an array Data of doubles, an array containing all the indices of Data's minimums. Does it exist?
Thanks!
Edit: How to do in the particular case the minimum is 1?
  댓글 수: 2
Walter Roberson
Walter Roberson 2013년 6월 25일
Is this a vector to be worked on, and you want to return a possible vector of indices?
Is this an array to be worked on, and the minimum is to be taken over the entire array and the indices are to be the sequential indices numbers ("ind")?
Is this an array to be worked on, and the minimum is to be taken over one of the dimensions, with a vector of indices for each collapsed dimension? e.g., min of a 2D array per row, and vector of indices per row reflecting the min over that one row?
Martin
Martin 2013년 6월 25일
I think an example would be clearer.
I search a function Fun that returns:
Fun([1 2 3]) --> 1 Fun([2 3 6 8 4 9 2]) --> [1 7] Fun([1 0 1 0 1 0 1 0]) --> [2 4 6 8]
Is it clearer? Does this exist?

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

답변 (1개)

Richard Brown
Richard Brown 2013년 6월 25일
It doesn't feel very satisfactory, but this will do the trick
I = find(A == min(A))
  댓글 수: 2
Martin
Martin 2013년 6월 25일
That's great. Thank you!
Walter Roberson
Walter Roberson 2013년 6월 25일
Yes, that will work for vector input. It will not work for array inputs, which have not really been ruled out yet (giving an example with vectors is not the same thing as saying that non-vectors will not be used.)

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

카테고리

Help CenterFile Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by