我有一个这样的向量:
>> 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
向量已排序。每个值可以有任意数量。我需要找到每个值最后出现的索引。在这种情况下,它会返回这个:
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"