Determining the hourly time series from 5 minutes and 15 minutes time series data
조회 수: 15 (최근 30일)
이전 댓글 표시
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
답변 (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.
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
Lei Hou
2022년 2월 15일
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
참고 항목
카테고리
Help Center 및 File Exchange에서 Dates and Time에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!