Daily average of several years data
Show older comments
Hi!
I have SST data from 1981-2019. I'd like to calculate the daily average for each day of the year.
So the value for each day is the average of the SST of the 39 years.
The structure of the data is like this:
sst_date=[day,month,year,sst];
I'm thinking about looping sst_date, but is very confusing because the months and some years have different days.
Is there any way easier?
Thank you
4 Comments
jonas
on 9 Jul 2020
Could you provide a segment of the data?
JAIME DIEGO RICO
on 9 Jul 2020
madhan ravi
on 9 Jul 2020
? It only contains a year
JAIME DIEGO RICO
on 9 Jul 2020
Accepted Answer
More Answers (2)
This will probably work
[~,~,G] = unique([SST(:,1),SST(:,2)],'rows')
out = splitapply(@mean,SST(:,4),G);
You should end up with one value for each day of the year
2 Comments
JAIME DIEGO RICO
on 10 Jul 2020
jonas
on 10 Jul 2020
ops.. my bad. I've updated the answer for future reference :)
Kelly Kearney
on 9 Jul 2020
0 votes
You might also take a look at reshapetimeseries.m (part of the Climate Data Toolbox). Setting the 'bin' option to 'date' will reshape data into a year x day-of-year matrix (even if there are days without data), and takes care of the messiness associated with leap days.
1 Comment
JAIME DIEGO RICO
on 10 Jul 2020
Categories
Find more on Calendar 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!