Calculating Monthly average from daily data

10 visualizaciones (últimos 30 días)
saintmoon kim
saintmoon kim el 27 de Mayo de 2020
Comentada: darova el 1 de Jun. de 2020
Hi, I am having problem with calculating monthly average from daily data
I have a data set Matrix [year month day value].
I want to calculate every monthly average from daily data.
Problem is, 1 month have 28 29 30 31 days. I have 40 years data.
Help me :(
  5 comentarios
Rena Berman
Rena Berman el 31 de Mayo de 2020
(Answers Dev) Restored edit
darova
darova el 1 de Jun. de 2020
thanks

Iniciar sesión para comentar.

Respuesta aceptada

darova
darova el 27 de Mayo de 2020
Editada: darova el 27 de Mayo de 2020
Try this
k = 1;
month(end+1,:) = month(end,:)*nan;
s = 0;
for i = 1:length(month)-1
s = s + value(i);
if month(i) ~= month(i+1) % if next month
month(k:i,2) = s/(i-k+1); % calculate average and write to 2d column
s = 0; % rest sum varibale
k = i; % month counter (start)
end
end

Más respuestas (0)

Categorías

Más información sobre Line Plots en Help Center y File Exchange.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by