Suppose I have 2 input vectors x
and reset
of the same size
x = [1 2 3 4 5 6]
reset = [0 0 0 1 0 0]
and an output y
which is the cumulative sum of the elements in x
. Whenever the value of resets corresponds to 1, the cumulative sum for the elements reset and start all over again just like below
y = [1 3 6 4 9 15]
How would I implement this in Matlab?