
Re: Sum of consecutive positive values in vector
Posted:
Jun 8, 2014 8:16 AM


There is really no need of converting in string and using strfind(). One can deal with only pure numerical operations.
B = [0 A 0]; i = find(abs(diff(B>0))==1); C = cumsum(B); S = C(i(2:2:end))C(i(1:2:end))
% Bruno

