필터 지우기
필터 지우기

Sub-scripting a table

조회 수: 1 (최근 30일)
Lui
Lui 2019년 2월 19일
댓글: Lui 2019년 2월 20일
Hi everyone,
I have an 8928x41 table with datetime values in the first column. I am trying to group the values in this table according to time.
I have done this with a similar table to retrieve data for particular monthsa and yeasr as below:
T1=T(2010==year(T.Date),:); % Retrieves the data for the year 2010
T2=T(7==month(T.Date),;); % retrieves the data for July
I assume that if I do the same thing for the hour, it will yield the results but below is a sample of the results I got from the data set
hour20=MarchData(20==hour(MarchData.Date),:);
sample.PNG
How can I get data for hour 20 (20:00) alone?
Secondly Can someone help me write an iteration to do this for the 24 hours in a day?
Thank you.
  댓글 수: 1
Peter Perkins
Peter Perkins 2019년 2월 20일
It's not really clear what you are asking. If you want the one row for 8pm on that day, you aren't grouping anything. And it's not clear what you want to do with the groups of data.
In any case, it usually true that you don't need to explicitly separate the data into groups. Things like varfun, groupsummary, and splitapply are happy to work across all groups for you.
Consider puttig your data in a timetable, and using retime with one of the aggregation syntaxes to reduce your data to hourly values, if that's what you are trying to do.

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

채택된 답변

per isakson
per isakson 2019년 2월 20일
편집: per isakson 2019년 2월 20일
Try and replace
hour20=MarchData(20==hour(MarchData.Date),:);
by
clock2000 = MarchData((hour(MarchData.Date)==20 & minute(MarchData.Date)==0),:);
  댓글 수: 1
Lui
Lui 2019년 2월 20일
Thank you. This worked

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Timetables에 대해 자세히 알아보기

태그

제품


릴리스

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by