필터 지우기
필터 지우기

Cumulative sum function of daily rainfall

조회 수: 2 (최근 30일)
Saleem Sarwar
Saleem Sarwar 2015년 10월 1일
댓글: Walter Roberson 2015년 10월 1일
I have a large daily rainfall data and require to create a new series with rainfall of 1, 2 , 3 and 4 day will be same as observed, then day 5 rainfall will be sum of 1, 2,3, 4 and 5 day rainfall. 6 day rainfall will be sum of rainfall of 2, 3, 4, 5 and 6 day rainfall. Repeat this function for 50 years daily rainfall data. Could any body suggest me matlab script for this kind of analysis? data file will be like this
date rainfall Cumulative rainfall
1/1/1950 10 10
1/2/1950 0 0
1/3/1950 0 0
1/4/1950 0 0
1/5/1950 15 25
1/6/1950 5 20
1/7/1950 10 35
1/8/1950 7 42
.........

채택된 답변

Walter Roberson
Walter Roberson 2015년 10월 1일
conv() the rainfall data with one(1,5)
  댓글 수: 2
Saleem Sarwar
Saleem Sarwar 2015년 10월 1일
편집: Walter Roberson 2015년 10월 1일
Thanks Walter. This function has not solved my problem fully. The output is like that
Rainfall Cumulative after using Conv function Remarks
37 84 1st three days
41 126 1 to 4 days
6 155 1 to 5 days
42 123 2 to 6 days
29 95 3 to 7 days
5 114 4 to 8 days
I require following output
Rainfall Cumulative after using Conv function Remarks
37 37 1st day
41 41 2nd day
6 6 3rd day
42 126 4 day
29 155 1 to 5 days
5 123 2 to 6 days
Thanks
Walter Roberson
Walter Roberson 2015년 10월 1일
If you let the rainfall be stored in the column vector r, then
cr = cumsum([0;r]);
col2 = [r(1:4);ss(6:end)-ss(1:end-5)];
[r,col2]
Or
col2 = [r(1:4); conv(r, ones(1,5), 'valid')]; %one step
[r,col2]

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by