How to get the longest consecutive values in a column vector and the position at which it starts
Show older comments
Hello,
Suppose i have a single column vector A'=[0 0 0 1 0 1 1 1 0 0 0 0 0 1 1 1 1 1 1 1 1 1]
I only want the longest consecutive values of 1's and display only that.
I'd really appreciate any help!
Accepted Answer
More Answers (2)
Walter Roberson
on 24 Aug 2019
0 votes
1 Comment
Meghana Balasubramanian
on 24 Aug 2019
Benjamin Hezrony
on 6 Oct 2024
0 votes
It can also be done in one line:
B = bwareafilt(A,1)
A classic function in segmentation!
https://www.mathworks.com/help/images/ref/bwareafilt.html#d126e42061
Categories
Find more on Matrix Indexing 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!