MATLAB: Index of all smallest element

index smallest element

Hi
I have an array A=[2 2 3 4 1 3 4 1 9 1]; I can find the minimum element by [M I]=min(A); I got M=1 and I=5. But I would like my answer as M=1 and I=5, 8 and 10. (that is index of all elements that contain smallest element). How can I write my code. Any help would be greatly appreciated.

Best Answer

The find funciton is the easiest way to do this"
A=[2 2 3 4 1 3 4 1 9 1];
MinIdx = find(A == min(A))
MinIdx =
5 8 10