I've a vector
A = [0;1;1;1;0;0;1;1;1;2;2;2;2];
and I want to count the number of equal adjacent values in order to have a matrix like this:
B=[0 1
1 3
0 2
1 3
2 4];
can you help me?
Here is a short solution:
J=find(diff([A(1)-1; A]));
B=[A(J), diff([J; numel(A)+1])];