MATLAB: How to find the iteration number which gave me specific result

iteration

Say I am generating an array in matlab using for loop. In that array I have to find which value is minimum, so I used min function to find out. No I want to find out which iteration gave that result. How can I achieve this?

Best Answer

Store the iteration number as well as the minimum.
Or just use min with two outputs
[minv, idx] = min(A)