Using the find function to pick out data when it crosses a limit

16 visualizaciones (últimos 30 días)
shobhit mehrotra
shobhit mehrotra el 22 de Jun. de 2015
Comentada: Guillaume el 22 de Jun. de 2015
I have a vector
A= [12 34 56 78 94 104 160 199 233 277 287 300 302 309 345 4 26 45 66 77 89 123 234 280 321 344 6 13 ...]
where A, is in degrees. Everytime the value crosses 240, I want to find the index number right before the cross, so in this case [9 23]
find(AA crosses zero)
Thanks!

Respuestas (1)

Guillaume
Guillaume el 22 de Jun. de 2015
find( AA(1:end-1) < 240 & AA(2:end) > 240)
Note that if you're going to use the values returned by find to index an array, then you can dispense with the find and just use the logical array within the find for indexing.
  2 comentarios
shobhit mehrotra
shobhit mehrotra el 22 de Jun. de 2015
It doesnt work, it only selected the indices when it crosses zero, not 240. Please help Thanks
Guillaume
Guillaume el 22 de Jun. de 2015
Other than the mispelling in the variable name ( AA instead of A), the above does work exactly as you asked.
It finds the position of elements in AA which are strictly smaller than 240 AND for which the next element is greater than 240.
>>A = [12 34 56 78 94 104 160 199 233 277 287 300 302 309 345 4 26 45 66 77 89 123 234 280 321 344 6 13];
>>find( A(1:end-1) < 240 & A(2:end) > 240)
ans =
9 23

Iniciar sesión para comentar.

Categorías

Más información sobre Operators and Elementary Operations en Help Center y File Exchange.

Etiquetas

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by