I have an array [0,0,0,0,123,0,138,44,123,0,0,0,0,0,135,0,123,0,0,125........] I want to find starting and ending index for pattern [123,0] like[5,6,9,10....] Please help me find the ending indices
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Devansh Patel
el 14 de Jun. de 2018
Comentada: Devansh Patel
el 14 de Jun. de 2018
I can find the starting index using below function. function start = findPattern2(array, pattern)
len = length(pattern);
start = find(array==pattern(1));
endVals = start+len-1; start(endVals>length(array)) = [];
for pattval = 2:len
locs = pattern(pattval) == array(start+pattval-1);
start(~locs) = [];
end
0 comentarios
Respuesta aceptada
Más respuestas (0)
Ver también
Categorías
Más información sobre Shifting and Sorting Matrices 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!