How to sum every 29 data and make some condition for them?
2 ビュー (過去 30 日間)
古いコメントを表示
I have data for a long time. I would sum them every 30 times continuously (first row to 30th row, then second row to 31th row and 3th row to 32 and ............... to end). finally, I would do some conditions. I attached an excel file to show clearly what is that. I would have it by codes in matlab. is there any way to do that?
0 件のコメント
採用された回答
Guillaume
2016 年 7 月 19 日
For your moving sum, use movsum (available since r2016a, before that use a convolution). You can then test all values at once with vectorised comparison:
rainfall = readtable('sample.xlsx', 'Range', 'A1:B43082');
movingsum = movsum(rainfall.Rainfall_mm_, 30, 'EndPoints', 'discard');
%prior to 2016a:
%movingsum = conv(rainfall.Rainfall_mm_, ones(30, 1), 'valid');
condition1 = movingsum > 0.5;
condition2 = condition1(1:end-1) & ~condition1(2:end);
その他の回答 (1 件)
参考
カテゴリ
Help Center および File Exchange で Spreadsheets についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!