Daily average of several years data
Ältere Kommentare anzeigen
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 Kommentare
jonas
am 9 Jul. 2020
Could you provide a segment of the data?
JAIME DIEGO RICO
am 9 Jul. 2020
madhan ravi
am 9 Jul. 2020
? It only contains a year
JAIME DIEGO RICO
am 9 Jul. 2020
Akzeptierte Antwort
Weitere Antworten (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 Kommentare
JAIME DIEGO RICO
am 10 Jul. 2020
jonas
am 10 Jul. 2020
ops.. my bad. I've updated the answer for future reference :)
Kelly Kearney
am 9 Jul. 2020
0 Stimmen
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 Kommentar
JAIME DIEGO RICO
am 10 Jul. 2020
Kategorien
Mehr zu Calendar finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!