Calculating Monthly average from daily data

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
darova 2020 年 5 月 28 日
DOn't remove your question. Let it be. Restore it if possible
John D'Errico
John D'Errico 2020 年 5 月 28 日
編集済み: John D'Errico 2020 年 5 月 28 日
When you remove your question, you make the answer useless, out of context. That is an insult to the person who spent the time to answer your question. It damages Answers as a site for others to gain from, because nobody else can learn from this answer. An answer is meaningless without the context of the question behind it.
If you cannot stomach leaving your question there for others to see, you should not have asked the question in a public forum in the first place.
darova
darova 2020 年 5 月 28 日
編集済み: darova 2020 年 5 月 28 日
The main thing for me is accepting my answer
Rena Berman
Rena Berman 2020 年 5 月 31 日
(Answers Dev) Restored edit
darova
darova 2020 年 6 月 1 日
thanks

サインインしてコメントする。

 採用された回答

darova
darova 2020 年 5 月 27 日
編集済み: darova 2020 年 5 月 27 日

0 投票

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 件)

カテゴリ

ヘルプ センター および File ExchangeHistorical Contests についてさらに検索

質問済み:

2020 年 5 月 27 日

コメント済み:

2020 年 6 月 1 日

Community Treasure Hunt

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

Start Hunting!

Translated by