How to find longest lasting event

조회 수: 1 (최근 30일)
Attaullah Shafiq
Attaullah Shafiq 2020년 5월 24일
답변: ahmed ibrahim 2021년 1월 11일
How to find longest lasting event?
means i wanna Calculate the duration of each event as the difference between 2 function..
  댓글 수: 1
dpb
dpb 2020년 5월 24일
If use the duration class variable, then it's a simple as subtraction...

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

답변 (2개)

Image Analyst
Image Analyst 2020년 5월 24일
What form is your event data in? Is it like a binary vector [0,1,1,1,0,0,0,1,1,1,1,1,1,0,0,0]?
% 1's are in the event and 0's are where the event is not happening.
inEvent = logical([0,1,1,1,0,0,0,1,1,1,1,1,1,0,0,0])
% Extract the longest one and sum up the number of indexes of it.
longestDuration = sum(bwareafilt(inEvent, 1))
inEvent =
1×16 logical array
0 1 1 1 0 0 0 1 1 1 1 1 1 0 0 0
longestDuration =
6
  댓글 수: 7
dpb
dpb 2020년 5월 24일
@IA, groupsummary is relatively recent addition to the splitapply workflow toolkit -- R2018x? I think or thereabouts.
It's another case of essentially the same functionality as a Toolbox function being migrated to base product excepting w/ a different name and slightly different syntax.
Image Analyst
Image Analyst 2020년 5월 24일
Right you are. Cool, thanks. 👍

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


ahmed ibrahim
ahmed ibrahim 2021년 1월 11일
What row in the data set does this correspond to (remember that min and max have a 2nd output that gives the row)?

카테고리

Help CenterFile Exchange에서 Get Started with MATLAB에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by