How to extract data between start and end points of flood as separate events?

조회 수: 3 (최근 30일)
Hazhan Majeed
Hazhan Majeed 2021년 4월 20일
편집: Walter Roberson 2021년 4월 20일
Hello,
I have a code that calculates Start, Peak, and end points for a specified peak over threshold flood. i.e., the number of peakes indicates the number of flood events that exceeds a threshold in that dataseries. now i want to extract the data for each event and use it as separate variables. can anyone helpe with this please?? i have included an example for demonstration of what i neet.
peak points=(1:n)
start points=(1:n)
end points=(1:n)
ev1(data)=data between st(1):en(1)
ev2(data)=data between st(2):en(2)
.
.
ev(n)(data)=data between st(n):en(n)

답변 (1개)

Walter Roberson
Walter Roberson 2021년 4월 20일
ev = arrayfun(@(sp, ep) peakpoints(sp:ep), start_points, end_points, 'uniform', 0);
  댓글 수: 2
Hazhan Majeed
Hazhan Majeed 2021년 4월 20일
Hi Walter Robenson
thanks for your help. it gives me this error
ev = arrayfun(@(shloc,ehloc) pksloc(shloc:ehloc), shloc, ehloc, 'uniform', 0);
Nonfinite endpoints or increment for colon operator in index.
Error in @(shloc,ehloc)pksloc(shloc:ehloc)
Walter Roberson
Walter Roberson 2021년 4월 20일
편집: Walter Roberson 2021년 4월 20일
Could you confirm that your shloc and ehloc are indices, and not x values? And also that none of the values is -inf or inf or nan ?
Also, I recommend against using the same dummy variable names for the anonymous function as you use full variable names: what you did gets confusing over whether at any point the name refers to the vector or to a particular entry in the vector. That is why I used sp and ep instead of start_points and end_points to make it clear within the anonymous function call that you were working with single values passed in at that point, not with the entire vector.

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

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by