Daily average of several years data
Afficher commentaires plus anciens
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 commentaires
jonas
le 9 Juil 2020
Could you provide a segment of the data?
JAIME DIEGO RICO
le 9 Juil 2020
madhan ravi
le 9 Juil 2020
? It only contains a year
JAIME DIEGO RICO
le 9 Juil 2020
Réponse acceptée
Plus de réponses (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 commentaires
JAIME DIEGO RICO
le 10 Juil 2020
jonas
le 10 Juil 2020
ops.. my bad. I've updated the answer for future reference :)
Kelly Kearney
le 9 Juil 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 commentaire
JAIME DIEGO RICO
le 10 Juil 2020
Catégories
En savoir plus sur Calendar dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!