フィルターのクリア

Monthly average from daily data

1 回表示 (過去 30 日間)
Ana
Ana 2014 年 3 月 16 日
編集済み: Mischa Kim 2014 年 3 月 16 日
Hello,
I have one column with daily data, defined as double. How can I get into another column an average for every 30 days of daily data, to then get monthly averages? So for every 30 values of daily data, I would get one monthly average. I have 114502 daily observations. i don't care if the 30 days aren't exactly from each month, I just want 30-day averages.
I'm new to matlab, any help would be appreciated. thank you.

回答 (1 件)

Mischa Kim
Mischa Kim 2014 年 3 月 16 日
編集済み: Mischa Kim 2014 年 3 月 16 日
Filipa, use something like
data = [data; zeros(1,30*round(numel(data)/30)-numel(data))]
avdata = mean(reshape(data,numel(data)/30,[]))
The first command adds zeros at the end of the data vector to allow for reshaping the vector into a 30-by-N array. This way you can easily take averages of all N columns.

カテゴリ

Help Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by