how to find the line number of a point in a vector

4 visualizaciones (últimos 30 días)
gjashta
gjashta el 4 de Sept. de 2019
Comentada: gjashta el 4 de Sept. de 2019
I have a vector i=[0 0 1 1 1 1 0 0 0 0 0 0 1 1 1 1 1 0 0 0 0 0 1 1 1 1 0 0 0 0].
What can I use to find in which line number starts and ends number 1 each time?

Respuesta aceptada

madhan ravi
madhan ravi el 4 de Sept. de 2019
Start = strfind([0,ii],[0 1])
End = strfind([ii,0],[1 0])

Más respuestas (1)

Fangjun Jiang
Fangjun Jiang el 4 de Sept. de 2019
Editada: Fangjun Jiang el 4 de Sept. de 2019
a=diff(i)
find(a==1)
find(a==-1)
adjust by 1

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by