count number values exceeds given threshold in moving window

2 ビュー (過去 30 日間)
Jay Hanuman
Jay Hanuman 2016 年 10 月 27 日
コメント済み: Walter Roberson 2016 年 10 月 27 日
I have time vs values plot. time =100. I want to select time 1 to 4 & then count how many values are exceeding 20. i.e. for time 1 to 4 values are 16 43 94 21 so 3 values are exceeding 20 so count should be 3. then want move window so time is 2 to 5 & count number of values exceeding 20. so last window would be 97 to 100. how to do it.

回答 (1 件)

Fangjun Jiang
Fangjun Jiang 2016 年 10 月 27 日
M=100;
N=4;
A=randi(35,1,M);
B=A>20;
C=ones(N,M-N);
C(1,:)=1:(M-N);
C=cumsum(C);
D=sum(B(C));

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by