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

Posted 10 years ago
7846 Views
|
2 Replies
|
3 Total Likes
|
 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?CHeers
2 Replies
Sort By:
Posted 10 years ago
 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 10 years ago
 I just find a solution.The command Position can do that.For further information http://reference.wolfram.com/mathematica/ref/Position.htmlIt is so easy! I love mathematica!