Hi,
I would like to get the index number of the first five minimum number from the list. This is my code:
list = [4,10,1,2,7,12,5,6,10,8];min=list(1,1)ind = 1;N = length(list)t= 0;while (t<5) for n = 2:N if min>list(n) ind=n; min=list(n); end end minIndexList(1,t+1) =ind ; t = t+1; enddisp(minIndexList)
However, the code just stored and repeat the index of the minimum Fors insance, minIndexList just stored >> 3,3,3,3,3. By right, the minIndexList should store = 3,4,1,7,8. Do anyone can help me to solve this problem? Thank you in advance
Best Answer