>> t = datetime(2020,1,1) + hours(0:2:365*24)';
>> tt = timetable(rand(size(t)),'RowTimes',t);
>> summer = ismember(month(tt.Time),3:8);
>> tod = timeofday(tt.Time);
>> summerDayTime = summer & (hours(5) < tod & tod < hours(22));
>> winterDayTime = ~summer & (hours(8) < tod & tod < hours(18));
>> ttDaytime = tt(summerDayTime | winterDayTime,:);
>> ttDaytime(1:10,:)
ans =
10×1 timetable
Time Var1
____________________ ________
01-Jan-2020 10:00:00 0.47859
01-Jan-2020 12:00:00 0.88889
01-Jan-2020 14:00:00 0.55983
01-Jan-2020 16:00:00 0.24912
02-Jan-2020 10:00:00 0.64779
02-Jan-2020 12:00:00 0.95873
02-Jan-2020 14:00:00 0.51567
02-Jan-2020 16:00:00 0.012846
03-Jan-2020 10:00:00 0.75199
03-Jan-2020 12:00:00 0.035388
>> ttDaytime(501:510,:)
ans =
10×1 timetable
Time Var1
____________________ _______
02-Apr-2020 14:00:00 0.28218
02-Apr-2020 16:00:00 0.70203
02-Apr-2020 18:00:00 0.93884
02-Apr-2020 20:00:00 0.83015
03-Apr-2020 06:00:00 0.29995
03-Apr-2020 08:00:00 0.43387
03-Apr-2020 10:00:00 0.43982
03-Apr-2020 12:00:00 0.47928
03-Apr-2020 14:00:00 0.18956
03-Apr-2020 16:00:00 0.49738
Best Answer