Find index of last occurrence for each value
问题 I have a vector like this : >> v = [1 1 1 2 2 3 4 4 4 4 4 5 5]' v = 1 1 1 2 2 3 4 4 4 4 4 5 5 The vector is sorted. There can be any number of each values. I need to find the index of the last occurence of each value. In this case, it would return this : answer = 3 % index of the last occurence of "1" 5 % index of the last occurence of "2" 6 % index of the last occurence of "3" 11 % index of the last occurence of "4" 13 % index of the last occurence of "5" 回答1: Thanks to @trumpetlicks, the