MATLAB Answers

Hourly averages over a 20yr time series

2 ビュー (過去 30 日間)
Ross O'Connell
Ross O'Connell 2021 年 3 月 10 日
コメント済み: Ross O'Connell 2021 年 3 月 11 日
I have a 20yr time series of data with time values for each hour, so ~175,000 time values. I want to calculate an hourly mean for the time series, so for example on Jan 1st at 00:00:00, I will have 20 values at this time over the 20 year series and I would like to calculate the mean, and so on for each date and time. The date and time values are formatted as '01-Jan-2000 00:00:00'.
  2 件のコメント
Ross O'Connell
Ross O'Connell 2021 年 3 月 11 日
Hi Steven,
Yes this is exactly how I want to add the data to the 'bins'.
I should have clarified further, the data is actually NetCDF, so the array for my variable is 21x11x175296 (so latitudexlongitudextime) and my time array is just 1 x 175296.
I found the following code from a previous query that I think was carrying out the same thing, but When I try to compute Y I am getting the following error:
Error using splitapply (line 99)
The data variables must have the same number of rows as the vector of group numbers. The group number vector has
175296 row(s), and data variable 1 has 21 row(s).
Day = day(Date,'dayofyear');
Hour = hour(UTtime);
[G,dayID,hourID]=findgroups(Day,Hour); % Added 3rd output
Y = splitapply(@mean,Temperature,G);


回答 (2 件)

Star Strider
Star Strider 2021 年 3 月 10 日
See if the groupsummary function will do what you want. The retime function is also an option.

Sargondjani 2021 年 3 月 10 日
Its not exactly clear over which values you want to calculate the mean, but have a look at this function, that can calculate moving averages:





Community Treasure Hunt

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

Start Hunting!

Translated by