필터 지우기
필터 지우기

detecting no. of events

조회 수: 2 (최근 30일)
Heartrin
Heartrin 2015년 11월 5일
댓글: Heartrin 2015년 11월 5일
I have an array of 2000x1 = D .
i have a condition D>25. for D>25 higher than 20 sec i should count 1 event.
how can i do this in matlab?

채택된 답변

Thorsten
Thorsten 2015년 11월 5일
편집: Thorsten 2015년 11월 5일
If D contains an entry every second, you can use:
D = randi(2000, 1, 20); % sample data
di = diff([0 D > 25 0]);
i1 = find(di == 1);
i2 = find(di == -1);
Nevents = nnz(i2 - i1 > 20);
  댓글 수: 3
Thorsten
Thorsten 2015년 11월 5일
What's the size of D? If it is 20000x1 as you said in your original post, then it should work. If it is 1x20000, you have to use
di = diff([0; D > 25; 0]);
Heartrin
Heartrin 2015년 11월 5일
Thanks . you are awesome.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by