I have a .txt file with precipitation data from one year as shown below. The columns shows year,month,day,hour,minute and the amount of precipitation.
2014,01,01,02,14,0.100
2014,01,01,02,24,0.100
2014,01,01,02,31,0.100
2014,01,01,02,44,0.100
2014,01,01,03,02,0.100
2014,01,01,03,29,0.100
2014,01,01,03,57,0.100
The precipitation has been measured each minute. I want to sum up the data so that I can find precipitation for 5 minutes, 30 minutes, 1 hour, 1 day and so on.
So for the data shown here, if I want to sum up the data for one hour I want to get an output like
2014,01,01,02,0.4
2014,01,01,03,0.3
I need this because I need to find the maximum precipitation for different time intervals during a year.

 채택된 답변

Andrei Bobrov
Andrei Bobrov 2016년 2월 6일

0 개 추천

f = fopen('name_of_your_txt_file.txt');
c = textscan(f,'%d %d %d %d %d %f','delimiter',',','CollectOutput' ,1);
fclose(f);
[a,b,c1] = unique(c{1},'rows');
out = [double(a),accumarray(c1,c{2})];

추가 답변 (1개)

Sigrid Johansen
Sigrid Johansen 2016년 2월 6일

0 개 추천

That works! Thank you!
With this I understand how to calculate the maximum precipitation for 1 hour, 1 day and 1 month. But how do I get the max value for 5 minutes, 30 minutes, 6 hours and so on?

카테고리

도움말 센터File Exchange에서 Weather and Atmospheric Science에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by