repeatedly selecting specific time intervals from timeseries
25 views (last 30 days)
i am doing some futures intraday analizis on dax and got the timedata in format of '28-Dec-2020 12:00:00' (24h format) because of a lot of missing datapoints outside the range of 09:00:00 till 17:30:00 i want to extract these.
my intention is to simply create a new dataset just with datapoints of all day but only within this time range. how can i select just the rows whitin a specific timeinterval.
thanks for your help
Pranjal Kaura on 1 Sep 2021
It is my understanding that you want to extract datapoints from a dataset based on the date-time information.
Here is a code snippet for your reference:
lowerTime_limit = datetime('28-Dec-2020 09:00:00');
upperTime_limit = datetime('28-Dec-2020 17:30:00');
time_Array = datetime(["28-Dec-2020 15:00:00", "28-Dec-2020 14:00:00", "28-Dec-2020 13:00:00", "28-Dec-2020 19:00:00"], 'InputFormat','dd-MMM-yyyy HH:mm:ss');
tf = isbetween(time_Array, lowerTime_limit, upperTime_limit) %tf is the required logical indexing
If you want to extract all days withtin a particular time range, you can refer to the following code for a possible workaround:
lowerTime_limit = convtoMin(datetime('09:00:00'));
upperTime_limit = convtoMin(datetime('17:30:00'));
time_Array = datetime(["28-Dec-2020 15:00:00", "28-Dec-2020 14:00:00", "28-Dec-2020 13:00:00", "28-Dec-2020 17:31:00"], 'InputFormat','dd-MMM-yyyy HH:mm:ss');
tf = [convtoMin(time_Array) >= lowerTime_limit & convtoMin(time_Array) <= upperTime_limit] %tf is the required logical indexing
function output = convtoMin(input)
output = input.Hour*60 + input.Minute;