How can I merge successive row values (sum of the values) of the column Y according to a condition in column X?
조회 수: 2(최근 30일)
표시 이전 댓글
Dear,
Hope everyone is doing well!
My issue is: I have a two data columns (X and Y) and datime column (10 min interval). I want to merge the successive row values (sum) of column Y if the corresponding values of column X are 0. Otherwise, if one of the X row equals to 1, then no merge.
Knowing that X contains only 0 and 1 values.
Thank you for your collaboration.

댓글 수: 2
답변(1개)
Peter Perkins
2022년 5월 18일
You want to do grouped sums, where the groups are defined by consecutive zeros in X. Once you have the groups defined as a new variable in (what should be) a timetable, it's a simple matter of calling groupsummary. Usually defining groups like that involves tricks with cumsum and diff. But without a clear example of what you have and what you want, I won't hazard a guess.
댓글 수: 0
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!