Extracting data in specific time intervals
Show older comments
Hi! I'm working with financial market HF data that looks like this:
Time Midpoint
_____________________ ________
20130102 01:00:00:558 30.33
20130102 01:00:01:272 30.325
20130102 01:00:02:228 30.325
20130102 01:00:02:308 30.33
20130102 01:00:02:892 30.337
20130102 01:00:03:517 30.338
20130102 01:00:05:298 30.331
20130102 01:00:13:857 30.337
20130102 01:00:14:296 30.337
20130102 01:00:14:417 30.33
What I want to do is, extract the price in column 2 at specific intervals, say 15 seconds. The problem is that the data is not equally spaced, so simply taking any xth value like this y:x:z doesn't work. Does anyone have an idea how to approach this?
Accepted Answer
More Answers (1)
Guillaume
on 11 Nov 2018
Since it appears your data is stored in a timetable, the simplest way would be to call retime with whichever aggregation method is most suitable ( 'nearest maybe?):
retime(yourtimetable, yourtimetable.Time(1): seconds(15): yourtimetable.Time(end), 'method', 'nearest')
Note that in R2018a or later, the above would be a lot simpler:
retime(yourtimetable, 'regular', 'nearest', 'TimeStep', seconds(15))
If your data is in a table convert it to a timetable with table2timetable.
Categories
Find more on Tables in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!