How to calculate daily mean from hourly data
6 次查看(过去 30 天)
显示 更早的评论
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?
采纳的回答
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
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.
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!