Determine if binary vector transitions from 1 to 0 to 1 again?
Ältere Kommentare anzeigen
Say I have a binary marix:
M = [1 1 1 1; 1 1 1 0; 1 1 0 1; 1 0 1 1; 1 1 0 0; 1 0 0 1; ...]
I want to eliminate the rows where there are any 0 'islands' in the middle of 1's. So in the above matrix I want to eliminate rows 3, 4, 6. If the rows were longer it wouldn't matter how many islands there are, e.g. [1 0 1 1 1 1 0 0 1] would be removed.
The answer given in the question below is related, but I am struggling in applying it to this problem. Some combination of diff() and cumsum() are needed I think. Thanks!
1 Kommentar
Antworten (1)
Kategorien
Mehr zu Loops and Conditional Statements finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!