consider a vector like 'e'. i wanted to do below conditions and create a new 'e' vector. conditions: If e(i)<5,then it must be replaced with e(i)+e(i+1) that it must be greater than 5,if don't, e(i) must be replaced with e(i)+e(i+1)+e(i+2) and so on. the modified vector can has different length from initial vector.
example:
e(old)=[2,6,10,4,3,6,1,2,3]
e(new)=[8,10,7,6,6]
actually i could write it with this script
clc;clear all
e=[2,6,10,4,3,6,1,2,3];
e_tmp=0;
k=0;
for i=1:size(e,2)
e_tmp=e(i)+e_tmp;
if e_tmp>=5
k=k+1;
A(k)=e_tmp;
e_tmp=0;
else
A(k+1)=e_tmp;
end
end
but, i want to write it with cumsum_function