# How can I track time periods under certain criteria?

4 vues (au cours des 30 derniers jours)
Daphne PARLIARI le 16 Fév 2021
Commenté : Duncan Po le 26 Fév 2021
Hello everyone!
I would appreciate your help on this. I have a dataset of daily counts of temperature (please find attached) for 11 years, 2006-2016.
What I want to do is to find all time periods that demonstrate three or more consecutive days with temperature higher than the 95th percentile (this way I am trying to locate heat waves). I also need the respective dates.
What I have tried so far
m=1;
days=0;
for i = 1: length(Daily_Meteo.Daily_T)
if Daily_Meteo.Daily_T(i)> 28
days = days + 1;
if days >= 3;
HWs(m,:) = Daily_Data.Daily_DATE(i);
m=m+1;
end
end
end
The problem is that HWs(m,:) holds all days with T>28oC, but I want only 3 or more consecutive days...
PS. I am on R2019b.
##### 0 commentairesAfficher -2 commentaires plus anciensMasquer -2 commentaires plus anciens

Connectez-vous pour commenter.

### Réponse acceptée

Duncan Po le 18 Fév 2021
You can put your data in a timetable and then use movsum like this:
tt.threehotdays = (movsum(tt.Daily_T > 28, [2 0]) == 3) ; % find all days when it and the previous 2 days are all above 28 degrees
##### 6 commentairesAfficher 4 commentaires plus anciensMasquer 4 commentaires plus anciens
Daphne PARLIARI le 26 Fév 2021
Thank you Duncan.
Is there a way to also count the number of HW episodes?
Duncan Po le 26 Fév 2021
Use diff:
d = diff(tt.threehotdays) == 1; % d is 1 at transition from 0 to 1
loc = find(d) + 1; % +1 because diff output starts at 2nd position

Connectez-vous pour commenter.

### Catégories

En savoir plus sur Object Detection dans Help Center et File Exchange

### Community Treasure Hunt

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

Start Hunting!

Translated by