Peaks over threshold counting events
Show older comments
Hi, I have a dataset with values with a time step of 3h. I need to find the values over a threshold i.e 7. When the value goes over 7 for some time and then down the threshold again counts as 1 event. I would like to count the number of events over that threshold for the whole data set. Attached the data: first column with the values, second column with the time.
Thanks
Accepted Answer
More Answers (2)
Guillaume
on 25 Sep 2017
If I understood correctly,
overthreshold = yourvalues > yourthreshold;
overstarts = strfind([0; overthreshold]; [0; 1]); %find starts of sequences above threshold
overends = strfind([overthreshold; 0], [1; 0]) + 1; %find ends of sequences
overlength = overends - overstarts;
eventcount = sum(overlength > yourminimumlength);
Andrei Bobrov
on 25 Sep 2017
Edited: Andrei Bobrov
on 25 Sep 2017
nnz(diff([0;Hs_hr(:,1)>7]));
or
nnz(filter([1,-1],1,(Hs_hr(:,1)>7)*2-1) == 2)
Categories
Find more on Descriptive Statistics in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!