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

3 views (last 30 days)
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)

Answers (1)

Walter Roberson
Walter Roberson on 20 Apr 2021
ev = arrayfun(@(sp, ep) peakpoints(sp:ep), start_points, end_points, 'uniform', 0);
  2 Comments
Hazhan Majeed
Hazhan Majeed on 20 Apr 2021
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 on 20 Apr 2021
Edited: Walter Roberson on 20 Apr 2021
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.

Sign in to comment.

Categories

Find more on Audio Processing Algorithm Design in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!