How to sum average annual data
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Let's say I have a code from date 1/1/2004 to 31/12/2018, and I have a data of 5479x1 for each day. How do I sum the data up for each year to obtain an annual data value for each year?
= datetime(2004,01,01):calmonths(1):datetime(2018,12,31);
0 comentarios
Respuestas (1)
KSSV
el 29 de Mayo de 2020
Convert your date time into d,m,y, using datevec. Pick a year you want, get it's indices and use mean. Let A be your data.
[y,m,d] = datevec(yourdates) ;
[c,ia,ib] = unique(y) ; % get unique years present
N = length(c) ; % Total number of years present
% loopfor each year
for i = 1:N
iwant(i) = mean(A(y==i)) ; % get mean of particular year
end
2 comentarios
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!