Message Boards Message Boards

2 Replies
3 Total Likes
View groups...
Share this post:

How to extract the position of a minimum value in a vector or a Matrix

Hello everybody,
I have been tryin to find a solution to this on the support page or on line but I didn't.

I am generating a list of numbers between 0 and 1, using a cicle and a function I wrote . Because I am trying to solve an optimization process I need to extract the smallest of this number (and this is easy using the function Min
    ) but I don't know how to extract the position of the minimum, in what position of the array the minimum value is stored. 

    So if list={0.1,0.03,0,4} The result of Min
      =0.03 How can I get the fact that the smallest value is in position 2 of the array list[[2]]??

      I need this information because will give me what parameters that generated that minimum value.

      Hope that it is clear. 
      Please could somebody help with this?
2 Replies
You can also use Ordering.
In[205]:= Ordering[{0.1, 0.03, 0, 4}, {1}]
Out[205]= {3}
(because the Min is actually 0, because 0 < 0.03).
POSTED BY: Jeremy Michelson
I just find a solution.
The command Position can do that.
For further information
t is so easy! I love mathematica!
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
or Discard

Group Abstract Group Abstract