Daily average of several years data
Mostrar comentarios más antiguos
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 comentarios
jonas
el 9 de Jul. de 2020
Could you provide a segment of the data?
JAIME DIEGO RICO
el 9 de Jul. de 2020
madhan ravi
el 9 de Jul. de 2020
? It only contains a year
JAIME DIEGO RICO
el 9 de Jul. de 2020
Respuesta aceptada
Más respuestas (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 comentarios
JAIME DIEGO RICO
el 10 de Jul. de 2020
jonas
el 10 de Jul. de 2020
ops.. my bad. I've updated the answer for future reference :)
Kelly Kearney
el 9 de Jul. de 2020
0 votos
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 comentario
JAIME DIEGO RICO
el 10 de Jul. de 2020
Categorías
Más información sobre Calendar en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!