Sum Like Kind (not cumsum)
정보
이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.
이전 댓글 표시
Suppose I have two vectors (A and B). Vector A contains year,month,day in serial format. Vector B contains _cumulative precipitation data (0, 0.01, 0.02, 0.03, NaN, 0.04, NaN, NaN, NaN, 0.05). Each event (bucket tip) is equal to 0.01 in. Note, NaN values are associated with no data measurements (i.e., no rainfall) and the rainfall data is cumulative. I've compiled this data in a matrix.
I'd like to determine the daily total precipitation amount. So I'd like to sum the precipitation values associated with a unique serial date (year, date, month) over the data range. I don't want to sum the whole column, I only want to sum all precipitation values associated with a unique serial date.
Any ideas?
댓글 수: 0
답변 (1개)
Honglei Chen
2012년 2월 1일
I don't know what the format is for your serial data so I'll just give an example where I add values of y when x is within a region. I hope this is what you look for.
x = [1 2 3 4 5 6]
y = [0.01 0.02 NaN 0.04 0.05 0.06]
x_nonan = x(~isnan(y))
y_nonan = y(~isnan(y))
sumval = sum(y((1<x)&(5<=x)))
댓글 수: 0
이 질문은 마감되었습니다.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!