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!