Extracting data in specific time intervals
이전 댓글 표시
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?
채택된 답변
추가 답변 (1개)
Guillaume
2018년 11월 11일
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.
카테고리
도움말 센터 및 File Exchange에서 Tables에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!