How to calculate Daily mean and monthly mean from hourly data?

조회 수: 22 (최근 30일)
Jeevan Kumar Bodaballa
Jeevan Kumar Bodaballa 2020년 2월 5일
댓글: Jack 2022년 8월 18일
I have hourly data for 5years continuasly and I would like to calculate daily mean and montly mean.
Sample data file attached

채택된 답변

Akira Agata
Akira Agata 2020년 2월 25일
I would recommend the following steps:
  1. Import the data file
  2. Arrange the data and create timetable variable
  3. Apply retime funciton to obtain daily/monthly average
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
Lejla Latifovic
Lejla Latifovic 2022년 4월 21일
Fabulous, thank you so much! I was able to get it to work and plot.
Jack
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 CenterFile Exchange에서 Dates and Time에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by