Finding when signal goes below threshold

3 ビュー (過去 30 日間)
Systematically Neural
Systematically Neural 2021 年 2 月 19 日
Hi,
I am trying to find when my data goes below a threshold, but not everytime it goes below threshold. Given a certain event when it goes below a threhsold (both in the forward and reverse direction). I have a logical matrix of 1's and 0's that signal when my data is above a threshold (1) and not (0)( attached low_thresh). I also have a matrix of of index locations where events occur (baseline_waves). For each location event, I want to find where the next place the data goes below the threshold (in both the forward and reverse direction). Specifically where these locations are and the distance between the occurence in the reverse and forward direction. Every location will be above the threshold, just as a side note. I have tried a few ways, but cannot seem to come up with a good way to do this.
Any help would be appreciated.

採用された回答

Image Analyst
Image Analyst 2021 年 2 月 19 日
Can't you just mask it, like
indexes = above_threshold & baseline_waves;
then examine that logical with find() or strfind()?
If not, post a picture of a plot of the data with threshold indicated and the "events" located, and the indexes you want to find in the forward and reverse directions (do you mean "first" and "last"? If not explain forward and reverse.)
  3 件のコメント
Image Analyst
Image Analyst 2021 年 2 月 21 日
% Find indexes above highThreshold
aboveHighIndexes = signal > highThreshold;
firstHigh = find(aboveHighIndexes, 1, 'first');
% "find when that signal for this event "first" went above the lower threshold"
% Make copy with values below the first index set to -inf
signalCopy = signal;
signalCopy(1:firstHigh - 1) = -inf;
% Now find where the signal is first above the lower threshold.
firstLow = find(signalCopy > lowThreshold, 1, 'first');
% Now find where the signal is first dives below the lower threshold, but after the first low index.
signalCopy(1 : firstLow) = inf;
nextLow = find(signalCopy <= lowThreshold, 1, 'first');
Attach actual data and expected results if you need more help.
Systematically Neural
Systematically Neural 2021 年 2 月 22 日
Yes, this is great. Setting to infinity was great. Thanks so much, as always Image Analyst for your help!

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMatrix Indexing についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by