v = [1,2,1,1,1,2,2]
1
and 2
are my two groups. I'm trying to increment each group by 1 every time there is a repetition
The desired result:
v2 =
1 1 2 3 4 2 3
I tried the functions cumsum
and movsum
with splitapply
, but nothing has worked so far