# Determining the hourly time series from 5 minutes and 15 minutes time series data

18 ビュー (過去 30 日間)
Manikandan Shanmugarajasekaran 2022 年 2 月 3 日

I'm having a time series data of rainfall (5 minutes interval) and temperature (15 minutes interval) in .csv file. I need to determine the hourly rainfall (1hour interval) ie. adding the twelve 5 minutes data together and repeating it for entire time series and save it in another .csv file. Similarly for temperature data, I need to determine the hourly temperature (1hour interval) ie. averaging the four 15 minutes data together and repeating it for entire time series and save it in another .csv file. I'm attaching the time series data in .csv format.

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

### 回答 (2 件)

David Hill 2022 年 2 月 3 日
It you were not missing data it would be an easy reshape. I think you are going to need to do datenum ranges. Convert first column to datenum values, then run loop summing the entries every hour. You might need to fill in missing data in column 2 with zero. Might take awhile to compute.
t=zeros(size(c,1)-1,1);
for k=2:size(c,1)
t(k-1)=datenum(c{k,1});
end
ti=t(1);%start time
interVal=0.04167;
rain=cell2mat(c(2:end),2);
count=1;
for k=ti+interVal:interVal:t(end)
rainHourly(count)=sum(rain(t>=ti&t<k));
ti=k;
count=count+1;
end
##### 0 件のコメント表示 -1 件の古いコメント非表示 -1 件の古いコメント

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

Lei Hou 2022 年 2 月 15 日
Hi Manikandan,
You can use timetable to store your data, and use retime to resample your data.
rainfall.DateTime = datetime(rainfall.DateTime,'InputFormat','dd-MM-uuuu HH:mm');
rainfallTT = table2timetable(rainfall);
rainfallHourly = retime(rainfallTT,'hourly','sum');
temperature.DateTime = datetime(temperature.DateTime,'InputFormat','dd-MM-uuuu HH:mm');
temperatureTT = table2timetable(temperature);
temperatureHourly = retime(temperatureTT,'hourly','mean');
writetimetable(rainfallHourly,'RainfallHourly.csv');
writetimetable(temperatureHourly,'TemperatureHourly.csv');
Thanks,
Lei

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

### カテゴリ

Find more on Time Series Objects in Help Center and File Exchange

### Community Treasure Hunt

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

Start Hunting!

Translated by