Home MATLAB: summing values in matrix up to a threshold level of one column
 So, I have a matrix with 2 columns and 5 rows (as an example). 2 1 5 1 3 1 4 1 7 1  what I want to do is: Starting from position (1,1) and moving down the first column, find the cells that lead to a value <10. In this case I would have: step 1: 2 = 10? No, continue step 2: 2+5 = 10? No, continue step 3: 2+5+3 = 10? Yes, stop and return the sum of the corresponding values in the second column step 4: 4 = 10? No, continue step 5: 4+7 = 10? No, it's larger, thus we save the previous step and return 1 form the second column.  In the end of this process I would need to obtain a new matrix that looks like this: 10 3 4 1 7 1