repeatedly selecting specific time intervals from timeseries

조회 수: 7(최근 30일)
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
Chunru 2021년 8월 20일
any details of timearray struct?

댓글을 달려면 로그인하십시오.


Pranjal Kaura
Pranjal Kaura 2021년 9월 1일
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;

Community Treasure Hunt

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

Start Hunting!

Translated by