Hint: What does diff give you? TRY IT!
x = [1 1 1 1 2 2 1 1 1 3 3 3 2];
What would happen if we tried find on that result? TRY IT!
This almost seems to work, but it does not find the first element. And, the index for that find was off by 1. Hmm. So now try this tweak.
x(find(diff([x(1) - 1,x])))
As you can see, I created a new vector, where I insured that it will always find the first element in the vector.
Could you have figured this out yourself? Well, yes. One thing to remember is the function diff returns zero, when two consecutive elements are the same. So diffi is a great tool to try when you are looking for when something CHANGES.
Next, how do you find when something has changed in that sequence? Find will do that for you, becauuse find locates non-zero elements.
After that, you just need to figure out how to get them both to work together, to find exactly the elements you want.
If you don't see how this works, take it apart, starting in the middle, then work out.