MATLAB: How to find the index of top k max values in the matrix

ambiguousarraycell arrays

A=[ 5 40 10 9 2 1 8 12 33 23]
find index of top 3 max values as:B= [ 2 9 10]
and return the rest index value in another array C=[1 3 4 5 6 7 8]
Thank you.

Best Answer

>> A=[ 5 40 10 9 2 1 8 12 33 23]
A =
5 40 10 9 2 1 8 12 33 23
>> [~,B]=maxk(A,3)
B =
2 9 10
>> C=setdiff(1:length(A),B)
C =
1 3 4 5 6 7 8