having a 2 months timetable with 10 minute data points, is it possible to extract first half of each day using subscripting?

having a timetable, one can do sub-scripting once on the hole interval. can one take a sub-script of the daily data of such a timetable, and save it in another timetable?

 채택된 답변

Yes, you can use subscript in MATLAB timetable class, similar to subscript in a MATRIX. For example to get the first half of the timetable you can use subscript like this
TT(1:end/2, :)
The exact detail of which subscript to use depends on the values you want to extract.
Edit: the updated answer according to your dataset is
TT_hours = hour(TT.Time);
index = d_hours <= 10 & d_hours >= 8;
TT_new = TT(index,:)
This will extract rows in which the hour is between 8 and 10.

댓글 수: 5

well, you've got 60 days more or less in two months ... you've got ~60 mornings which give you 60 x 8-10am intervals you need to pull out, not only one.
This command will pull out as many intervals as there are columns in the timetable, not just one. For specific code, you will need to share a sample dataset, so that we can see how the data is arranged.
I think you miss-understood the question or I did not ask properly. I want to extract the blue lines from the attached timetable without building a dedicated function. Your command extracts only interval 1:end/2. I want to extract multiple 8am-10am timeranges from a multi-day timetable. Hope I'm clear now !
Yes, The command posted in comments was just an example that timetable can use same indexing as matrices. Without watching a sample dataset, it is hard to suggest an exact solution. Please refer to updated answer.
Nothing wrong with Ameer's answer, but you might also try out
tr = timerange(hours(8),hours(10),'closed')
TTnew = TT(tr,:)

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

추가 답변 (1개)

Andy
Andy 2018년 5월 30일
that's the Pandas equivalent:
https://stackoverflow.com/questions/19179214/selecting-data-between-specific-hours-in-a-pandas-dataframe

제품

릴리스

R2018a

질문:

2018년 5월 30일

댓글:

2018년 6월 4일

Community Treasure Hunt

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

Start Hunting!

Translated by