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

11 ビュー (過去 30 日間)
shobhit mehrotra
shobhit mehrotra 2015 年 6 月 22 日
コメント済み: Guillaume 2015 年 6 月 22 日
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!

回答 (1 件)

Guillaume
Guillaume 2015 年 6 月 22 日
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 件のコメント
shobhit mehrotra
shobhit mehrotra 2015 年 6 月 22 日
It doesnt work, it only selected the indices when it crosses zero, not 240. Please help Thanks
Guillaume
Guillaume 2015 年 6 月 22 日
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

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeOperators and Elementary Operations についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by