# Help: Index that Falls above the lower variation limit if more than 50% of the data points in the following 20 point window are also above?

1 回表示 (過去 30 日間)
Dc215905 2021 年 7 月 1 日
コメント済み: Dc215905 2021 年 7 月 2 日
Hello,
I would like ot replicate an anlysis in the paper where they defined the offset as
"the first datum point that falls above the lower variation limit if more than 50% of the data points in the following 20 point window are also above the lower variation limit"
I've created an array that indicates the all indices that are above the lower variation threshold
Does anyone have a good solution to find the which datum fits th above criteria?
Right now, I've simply used diff(IndexAboveThresh) just to indicate consecutive datapoints, but I'm having trouble finding a way to complete the code.

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

### 採用された回答

Mohammad Sami 2021 年 7 月 2 日
You should create a logical array which is true for a point which is above the limit. Then we use a moving sum with a kf = 20 and kb = 0. We want a sum of 12 since sum is inclusive of current index plus next 20 points. So it would mean 11 points after this index satisfy the criteria which more then 50%. if you want more then or equal to 50% then we look for sum of 11.
% generate test data;
a = logical(randi([0 1],1000,1));
window_sum = movsum(a,[0 20]);
thresh = 12;
% a = true & window_sum >= thresh
firstdatumpoint = find(a & (window_sum >= thresh),1,'first');
firstdatumpoint = 7
##### 1 件のコメント-1 件の古いコメントを表示-1 件の古いコメントを非表示
Dc215905 2021 年 7 月 2 日
Thank you! This works great!

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

### カテゴリ

Help Center および File ExchangeImage Category Classification についてさらに検索

### Community Treasure Hunt

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

Start Hunting!

Translated by