Daily average precip for many years
Show older comments
I have a large matrix of two columns containing dates (eg 1/1/1991) and precip values. I want to create the average daily precip for all years from 1991-2016 such that the day of the year is in column 1 and the ave precip value is in column 2. I'm getting bogged down I believe because of leap years (not sure how to eliminate that date, which is fine). Any help would be greatly appreciated.
2 Comments
the cyclist
on 17 May 2018
Can you (ideally) upload your data in a MAT file, or (less ideally) give an example -- not just a description -- of how your input data are stored?
Thomas Burbey
on 18 May 2018
Accepted Answer
More Answers (1)
Razvan Carbunescu
on 18 May 2018
An alternative if using R2018a is groupsummary, it has a few different ways of selecting days for each week, month, year from a date:
>> GT = groupsummary(precip,'DATE','dayofyear','mean','Precipitation');
>> head(GT)
ans =
8×3 table
dayofyear_DATE GroupCount mean_Precipitation
______________ __________ __________________
1 26 3.2769
2 26 3.8
3 26 2.5
4 26 2.8423
5 26 3.9462
6 26 5.2192
7 26 2.1346
8 26 2.5346
2 Comments
Thomas Burbey
on 18 May 2018
dpb
on 18 May 2018
There's only a one-liner difference to generate the grouping variable, though, so it's only a relatively minor syntactic sugar refinement.
Note same results as above which is another independent confirmation of correct result.
Categories
Find more on Logical in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!