Calculate duration of Peaks using findpeaks function
Afficher commentaires plus anciens
Dear reader,
I am currently working on an analysis of storm events. I am interested in finding the duration of storms defined by windspeeds that exceed a particular threshold:
Currently, I have used the findpeaks() function to identify the location (timestamps) and maximum intensity (peak value) of the windspeeds. I have done this as follows:
[PKS,LOCS] = findpeaks(Windspeed,time,'MinPeakHeight',th)
Here, windspeed is a vector containing hourly windspeed measurements, time is vector with corresponding datenum values for the measurements of the windspeed. Finally, th is the thresholds for when windspeeds are considered a storm events.
Now, I also want to know the duration of the storm events. That is, the time between when the windspeed first exceeds th until it agains drops below th.
I have tried using 'WidthReference', however, this only gives the options 'halfprom' and 'halfheight' and both don't give the values I am looking for.
Can anyone help me with this. Many thanks in advance!
Réponse acceptée
Plus de réponses (1)
David Hill
le 10 Fév 2022
f=num2str(Windspeed>=th);
f=f(f~=' ');
[startIndex,endIndex]=regexp(f,'1*');
Duration=diff(datenum([time(startIndex),time(endIndex)])');
Catégories
En savoir plus sur Multirate Signal Processing dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
