Determining the hourly time series from 5 minutes and 15 minutes time series data
8 views (last 30 days)
Show older comments
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.
0 Comments
Answers (2)
David Hill
on 3 Feb 2022
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.
c=readcell('Rainfall.csv');
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 Comments
Lei Hou
on 15 Feb 2022
Hi Manikandan,
You can use timetable to store your data, and use retime to resample your data.
rainfall = readtable('Rainfall.csv');
rainfall.DateTime = datetime(rainfall.DateTime,'InputFormat','dd-MM-uuuu HH:mm');
rainfallTT = table2timetable(rainfall);
rainfallHourly = retime(rainfallTT,'hourly','sum');
temperature = readtable('Temperature.csv');
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');
Hoping this is helpful.
Thanks,
Lei
0 Comments
See Also
Categories
Find more on Tables 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!