I have a vector that looks like
a = [1 1 1 1 1 0 0 0 0 0 0 0 1 1 1 0 0 0 1 1 1 1….]
I would like to find the vector location where I would find the first 1, second 1, third 1 and so on, in the trains of 1's in a quickish way.
As an output… I would like new vectors containing only the first 1 in every sequence of 1's
eg
b = [1 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0....]c = [0 1 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0....]
OR
a Matrix containing the locations of each number in a sequence…
b = [1 13 19]c = [2 14 20]d = [3 15 21].... and so forth
Best Answer