Cumsum at different starting indices, append all previous value.
조회 수: 1 (최근 30일)
이전 댓글 표시
Hello, say I have 2 continuous dataset for example:
A = [0 0 8 0] B = [1 0 0 0 0.5 1.5 0]
The algorithm iterates over each element i = i +1 to check if element >= 0.5. If True cumsum starts.
Condition: Cumsum ends when exceeds 2 within 3 indices. Append the values and index.
The final cumsum value is not important, it is a means to set the condition of appending relevant values.
So result for A will give:
result = [0, 0, 8], idx = 1, 2, 3 NOT result = [ 0 0 8 '0']
However, if the condition is not met. Ignore the cumsum and move on to the next value.
e.g.: B will start 1st cumsum at [1]: 1 + 0 + 0 = 1. Which fails to meet the condition. Hence ignored.
It continues iterating, until reaching 0.5 which then starts another cumsum.
So result for B will give:
val = [1 0 0 0 0.5 1.5] NOT [1 0 0] [1 0 0 0 0.5 1.5 '0']
How can I approach this? Many thanks.
댓글 수: 3
답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Logical에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!