repeatedly selecting specific time intervals from timeseries

5 visualizzazioni (ultimi 30 giorni)
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
  2 Commenti
Marco G.
Marco G. il 19 Ago 2021
so, i nearly figured it out by myself.
new_timearray = timearray((timearray.Hour >= 9 & timearray.Hour < 18) == 1)
but actually i want between 17:30:00 and now im stucked again.

Accedi per commentare.

Risposte (1)

Pranjal Kaura
Pranjal Kaura il 1 Set 2021
Hey,
It is my understanding that you want to extract datapoints from a dataset based on the date-time information.
You can do the same using the isbetween function and the datetime date type.
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;
end

Categorie

Scopri di più su Characters and Strings in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by