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"
Thanks to @trumpetlicks, the answer is
unique.[EDIT]
In more recente version of the MCR (R2013 ?), the behavior of
uniquehas changed. To get the same result, you must useunique(v, 'legacy');