How to calculate the hourly data points?

조회 수: 4 (최근 30일)
aa
aa 2020년 11월 6일
댓글: Peter Perkins 2020년 11월 20일
Hi everyone,
May someone help me here ..
I have a long data in time-date formate i.e. six columns YYYY MM DD HH MM SS. Each time values indicate an observation. I want to calcualte the number of observations per hours. It is importanmt to mentioned that frequency of observations is uneven i.e. 10 or 100 obsservation per hour and no observation for a couple of days. So the output must account the missing time as well wehre there is no observation recorded.
Thank You!
  댓글 수: 2
KSSV
KSSV 2020년 11월 6일
Let the given date be t1.
Geenerate the dates required from start to end of the data with hourly difference. Let this be t2.
Then get the indices you want from t1 using ismember.
aa
aa 2020년 11월 6일
Thank you let me try this ... might be it will works but still i am not sure how this give me the event per data .. Ismember is something different from counts/hour ... I think so ,,, not sure ..

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

채택된 답변

Ameer Hamza
Ameer Hamza 2020년 11월 6일
편집: Ameer Hamza 2020년 11월 6일
Try retime():
T = readtable('data.xlsx');
t = datetime(T.YYYY, T.MM, T.DD, T.HH, T.MM_1, T.SS);
TT = timetable(t, ones(size(t)));
newTT = retime(tt, 'hourly', 'sum');
newT = table(newTT.t, newTT.Var1, 'VariableNames', {'Time', 'count'});
  댓글 수: 6
aa
aa 2020년 11월 6일
Thank you for guidence .. let me update my Matlab
Peter Perkins
Peter Perkins 2020년 11월 20일
Ameer solution is the right one, but actually, there's not really any need to turn newTT back into a table. You can leave it as a timetable.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Data Type Conversion에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by