how to calculate hourly averages?

56 次查看(过去 30 天)
Laura
Laura 2024-7-16,21:42
评论: Steven Lord 2024-7-17,0:39
I convertued my file to a csv, then used the following code to try and get hourly averages:
writematrix(NTU,'M.csv');
T1 = readtable('M.csv');
TT1 = table2timetable(T1,'RowTimes',NTU);
TT1 = retime(TT1, 'hourly','mean');
Am I using table2timetable wrong?
  5 个评论
Laura
Laura 2024-7-16,23:31
NTU 2856x1 22848 double
Steven Lord
Steven Lord 2024-7-17,0:39
So what do the values in NTU represent? Seconds since an epoch, days since an epoch, yyyymmdd, etc.?
Use those as inputs to datetime or duration (possibly with 'ConvertFrom' and the appropriate option for what your data represents) then use the datetime or duration array that call returns as your RowTimes. For example:
dt1 = datetime(19850621, 'ConvertFrom', 'yyyymmdd') % June 21, 1985 or
dt1 = datetime
21-Jun-1985
dt2 = datetime(1e8, 'ConvertFrom', 'epochtime') % 1e8 seconds since Jan 1, 1970
dt2 = datetime
03-Mar-1973 09:46:40
datetime(1970, 1, 1) + seconds(1e8)
ans = datetime
03-Mar-1973 09:46:40

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Tables 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by