Argmin with several minimums

2 views (last 30 days)
Martin
Martin on 25 Jun 2013
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 Comments
Martin
Martin on 25 Jun 2013
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?

Sign in to comment.

Answers (1)

Richard Brown
Richard Brown on 25 Jun 2013
It doesn't feel very satisfactory, but this will do the trick
I = find(A == min(A))
  2 Comments
Walter Roberson
Walter Roberson on 25 Jun 2013
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.)

Sign in to comment.

Categories

Find more on Resizing and Reshaping Matrices in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!