Daily average of several years data
Mostra commenti meno recenti
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 Commenti
jonas
il 9 Lug 2020
Could you provide a segment of the data?
JAIME DIEGO RICO
il 9 Lug 2020
madhan ravi
il 9 Lug 2020
? It only contains a year
JAIME DIEGO RICO
il 9 Lug 2020
Risposta accettata
Più risposte (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 Commenti
JAIME DIEGO RICO
il 10 Lug 2020
jonas
il 10 Lug 2020
ops.. my bad. I've updated the answer for future reference :)
Kelly Kearney
il 9 Lug 2020
0 voti
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 Commento
JAIME DIEGO RICO
il 10 Lug 2020
Categorie
Scopri di più su Calendar in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!