Determine if binary vector transitions from 1 to 0 to 1 again?
이전 댓글 표시
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개)
카테고리
도움말 센터 및 File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!