How to find all minimum elements in a vector

后端 未结 2 1256
太阳男子
太阳男子 2021-01-22 09:08

In Matlab, by the function min(), I can only get one single minimum element of a vector, even if there can be several equal minimum elements. I was wondering how to get the indi

2条回答
  •  滥情空心
    2021-01-22 09:19

    v = [1 2 3 1 5];
    find( v == min(v) )
    
    ans = 1 4
    

    At least in Octave (don't have matlab), this returns the indexes of all minimums in v

提交回复
热议问题