Good evening I have a matrix A 250*3, i try to do the following: the first time that the cumsum "of raws" is > 0.02 or lower than -0.02, i replace the corresponding value in matrix A with zero and restart the cumsum form the value after the zero. then we repeat this once more: the first time the new cumsum becomes >0.02 or <-0.02 we replace it with zero and restart the cum sum we repeat this untill we arrive to the last raw of the matrix. **with one condition like (cumsum>0.02) i have the following code.. However, i didn't arrive to add the new condition that (cumsum<-0.02).
x = unifrnd(-5,5,[250,2])/100;cum=cumsum(x);thresh = 0.02;while 1 xc = cumsum(x); k = find(xc > thresh,1,'first'); if isempty(k) % done
break end x(k) = -xc(k-1);end
Thank you in advance for your help
Best Answer