Remove consecutive values from vector
Mostrar comentarios más antiguos
Hey Guys,
I have this vector with increasing values (always positive) up till a certain point, after which it returns to zero again (straight line), and starts increasing again. A so called "saw" pattern. Now I am trying to determine the first indice in the vector which has a value above a certain threshold, but when I do so I get a vector with all of values above threshold.
It would be fixed if I could manage to remove the consecutive indices, and only store the first indice. I tried the following code, but this actually returns the last value of the consecutive numbers. (output is [3,7,12])
Any clue on how to change this to [1,7,10] ?
a = [1;2;3;7;10;11;12]
x = [diff(a')~=1,true];
a(x)
2 comentarios
Image Analyst
el 2 de Dic. de 2019
Huh? How is "a" a sawtooth pattern?

Rose
el 3 de Dic. de 2019
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Thermal Analysis 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!