Search for a number pattern in an array
Mostrar comentarios más antiguos
Without using strfind is there a way to search for a pattern of less than 4 ones in a row? and if there are can i set them all to zero and track which set of 1s it is and record in another array. Example below, 'a' being original data, 'b' is the updated data, 'newArr' nth set of any amount of 1's that was replaced with zeros. Let me know if i need to further clarify. thanks!
if true
a = [0 0 0 1 1 1 1 0 0 0 1 1 0 0 0 1 1 1 1 0 0 1 0 0 1 1 1 0]
BECOMES
b = [0 0 0 1 1 1 1 0 0 0 0 0 0 0 0 1 1 1 1 0 0 0 0 0 0 0 0 0]
newArr = [2 4 5]
end
2 comentarios
Guillaume
el 13 de Nov. de 2017
There are certainly many ways of doing it without strfind but what is the objection to using strfind if it fits the bill?
lightroman
el 13 de Nov. de 2017
Respuesta aceptada
Más respuestas (1)
Jan
el 13 de Nov. de 2017
0 votos
"Without using strfind"?! Why? Is this a homework? Then RunLength from the FileExchange might not be usable also. Then look in the code of RunLength_M to create your own efficient vectorized Run-Length method.
1 comentario
lightroman
el 13 de Nov. de 2017
Categorías
Más información sobre Octave en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!