- Import the data file
- Arrange the data and create timetable variable
- Apply retime funciton to obtain daily/monthly average
How to calculate Daily mean and monthly mean from hourly data?
25 次查看(过去 30 天)
显示 更早的评论
I have hourly data for 5years continuasly and I would like to calculate daily mean and montly mean.
Sample data file attached
0 个评论
采纳的回答
Akira Agata
2020-2-25
I would recommend the following steps:
The following is an example:
% Read the data file
opts = detectImportOptions('test_pog.txt');
T = readtable('test_pog.txt',opts);
% Make a datetime vector
Time = datetime(T{:,1},'InputFormat','yyyy.MM.dd.');
Time.Hour = T{:,2};
% Add the datetime vector and remove the 1st&2nd columns
T.Time = Time;
T(:,1:2) = [];
% Convert to timetable
TT = table2timetable(T);
% Apply retime function to obtain daily/monthly mean
TTdailyMean = retime(TT,'daily','mean');
TTmonthlyMean = retime(TT,'monthly','mean');
4 个评论
Jack
2022-8-18
Is there a way to use timetables to calculate statistics for a specific date?
For example, what is the average high temperature on July 4th over the last 30 years?
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Dates and Time 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!