Calculating Monthly average from daily data
5 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
darova
2020-5-27
编辑:darova
2020-5-27
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
0 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Line Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!