Now to replace all elements in sequence lesser then particular length
4 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hello to everyone,
I would like to ask how to replace all elements of one type in sequence that is lesser than particular length in a matlab vector of two types of elements.
For example we have this vector of elements(zeros and ones): 0 0 0 0 0 0 0 0 0 1 0 0 0 0 1 1 1 1 0 0 0 0 1 1 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0.
I would like to know how to replace ones for zeroes but only where the ones are behing each other in a sequence of maximum 5 length. So sequence 1 1 1 1 will be replaced for 0 0 0 0 in the vector but sequence 1 1 1 1 1 1 will stay the same. So the original vector woul look like this:
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0. Length of the vector stayes the same. I would also like to know to to do it more general for universal lengths of the sequences of ones that sould be replaced for 0. So for example I can have big vector where I want to replace all ones in sequence (or even single ones) shorter that 100 but keep the ones in sequences longer that 100 etc.
Thank you very much for hints.
0 comentarios
Respuestas (0)
Ver también
Categorías
Más información sobre Variables en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!