필터 지우기
필터 지우기

How to calculate daily mean from hourly data

조회 수: 10 (최근 30일)
Michael Omodara
Michael Omodara 2020년 7월 20일
답변: Steven Lord 2022년 10월 22일
I have hourly temperature data (without date and time) about 5200. I want to extract daily mean and store the output as a vector using a for loop. Can anyone give me useful suggestion?
  댓글 수: 1
Michael Omodara
Michael Omodara 2020년 7월 20일
Thank you for that. It was a quick fix for me.

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

채택된 답변

Star Strider
Star Strider 2020년 7월 20일
One approach:
T = 1:5200; % Temperature Vector
for k = 1:24:numel(T)
k2 = ceil(k/24);
idx = k:(min(k+23,numel(T)));
DailyMean(k2) = mean(T(idx));
end
There may be more efficient ways to do this, depending on what your temperature data actuallly are.

추가 답변 (1개)

Steven Lord
Steven Lord 2022년 10월 22일
If you have your data stored in a timetable array I recommend using the retime function to change the time basis of your data from hourly to daily.

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by