How to count how many times a number repeat in a sequence

3 views (last 30 days)
I have an matrix:
Result = [ 0 1 0 0 1 0 0 1 0 1 0 0 0 1 0 1 1 0 1 ....] so on until row 24.926
And i want to count in this way (how many times the zeros or one repeat and change in value):
One = [1 1 1 0 1 1 0 1 1 1 0 1 1 1 0 0 1 1 1 ...]
Two = [0 0 0 1 0 0 1 0 0 0 0 1 1 0 0 0 1 0 0 ...]
Three = [0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 ...]
Four = [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...]
Five = [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...]
Any good help is appreciated.

Accepted Answer

dpb
dpb on 9 Jun 2022
There are other similar submissions with slightly different functionalities; search at your heart's content.

More Answers (0)

Categories

Find more on MATLAB in Help Center and File Exchange

Tags

Products


Release

R2021a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!