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

3 visualizaciones (últimos 30 días)
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.

Respuesta aceptada

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

Más respuestas (0)

Categorías

Más información sobre MATLAB en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by