MATLAB Answers

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

1 view (last 30 days)
Hazhan Majeed
Hazhan Majeed on 20 Apr 2021
Edited: Walter Roberson on 20 Apr 2021
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
Walter Roberson
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.

Tags

Community Treasure Hunt

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

Start Hunting!