I have a vector, for example: a = [1 1 2 2 7 7 7 10 10 10 10 11 15]. It can be unsorted, but here I\'m writing it as sorted. I am looking for a Matlab command that will convert
There's at least two ways to do this
(1) use the third output of unique:
unique
[~,~,out] = unique(a)
(2) use grp2idx from the statistics toolbox
grp2idx
out = grp2idx(a)