Finding series of repeating numbers in matrix
1 view (last 30 days)
Show older comments
Michael Saniuk
on 13 May 2017
Commented: Michael Saniuk
on 13 May 2017
Hello, I am trying to find begginings and endings of repeating zeros in matrix, eg: for input matrix:
1 0 0 0 0 0 1 1 0 0 1 1 1 0 0 0 0 0 1 1 0 0 0 1 0 0 1
I want to get:
beggining = [2 9 14 21 25]
ending = [6 10 18 23 26]
Does anyone know how to do it?
0 Comments
Accepted Answer
More Answers (1)
Guillaume
on 13 May 2017
v = [1 0 0 0 0 0 1 1 0 0 1 1 1 0 0 0 0 0 1 1 0 0 0 1 0 0 1]
beginning = strfind([1 v], [1 0])
ending = strfind([v 1], [0 1])
Despite its name, strfind works with sequence of numbers as well.
See Also
Categories
Find more on Characters and Strings in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!