How to convert daily data to monthly?

21 ビュー (過去 30 日間)
Mohammad
Mohammad 2012 年 12 月 5 日
回答済み: ABHILASH SINGH 2020 年 3 月 13 日
I have huge number of precipitation daily data in a column (say for 60 years) for 400 meteorological stations. Now I need to convert it to monthly. How can I do that? thanks.
  2 件のコメント
per isakson
per isakson 2012 年 12 月 5 日
Months have 28, 29, 30 or 31 days, which makes it a bit tricky.
Do you have a table with
date, value
rather than just a column?
Does the length of the months matter?
Mohammad
Mohammad 2012 年 12 月 5 日
my data format is Year Month Day data
that is in 4 column. Length of month is always 30. Does it help for providing your answer? thanks.

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

回答 (5 件)

Andrei Bobrov
Andrei Bobrov 2012 年 12 月 5 日
編集済み: Andrei Bobrov 2012 年 12 月 5 日
one way
M - your data matrix with 4 columns < Year Month Day data > - double type
[a,~,c] = unique(M(:,1:2),'rows');
out = [a, accumarray(c,M(:,4),[],@mean)];

Chad Greene
Chad Greene 2014 年 11 月 5 日
downsample_ts can do this by
precip_monthlymean = downsample_ts(precip_daily,t_daily);
  2 件のコメント
ABDULLA RAHIL
ABDULLA RAHIL 2016 年 8 月 25 日
Hi Chad I tried to use this equation but i couldn't i have a daily data and want to have monthly data
Chad Greene
Chad Greene 2016 年 8 月 31 日
My mistake--
precip_monthlymean = downsample_ts(precip_daily,t_daily,'monthly','mean');

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


Babak
Babak 2012 年 12 月 5 日
Every 30 data rows, I would average them out and save it in 1 row.This way, 30 days shrinks down to 1 data (a month). Or another way, you can simply delete 29 data rows and keep only one from every 30 data rows.
  2 件のコメント
Mohammad
Mohammad 2012 年 12 月 5 日
Thanks. But please provide answer through matlab function.
Babak
Babak 2012 年 12 月 5 日
you need to write what your variables are and we would know which format they are... I mean what type they are for example, string? double, or cell? moreover they are all in a matrix or a cell or how you ahev sorted them..

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


per isakson
per isakson 2012 年 12 月 5 日
編集済み: per isakson 2012 年 12 月 5 日
Given thirty days in every month try this
daily_val = rand( 30*12, 1 );
daily_val = reshape( daily_val, 30, [] );
monthly_val = sum( daily_val, 1 );
here I assume that the first value in daily_val is the first value of a month. This is intended as a start.

ABHILASH SINGH
ABHILASH SINGH 2020 年 3 月 13 日

カテゴリ

Help Center および File ExchangeDates and Time についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by