MATLAB: (HELP) Algorithm that notice the moment that a vector with 2 columns varies

algorithm

Hello guys,
Im very new using matlab and programation.
I have a vector X with 200000 lines and 2 columns, the second column has only 0 and 1 (binary). I would like to make a algorithm that notice me everytime that the second column goes from 0 to 1.
Can someone help?
Thank you

Best Answer

you can use the diff() function on the second column. then use the find() function to see which items are 1 (the 0 to 1 transition), 0 (no transition 1 to 1 and 0 to 0, and -1 (1 to 0 transitions).
example:
transition = diff(X(:,2)); %get the diff of second column for all rows.
ZeroToOne = find(transition == 1);
the ZeroToOne variable will the the indexes where there is the 0 to 1 transition (located on the 0).