I have a matrix of data that looks like (my origninal data set is a 1450×6 matrix, but I think this matrix illustrates the problem)
A=[0.45 0.11 0.00 -0.32 1;-0.06 -0.18 0.62 0.20 1;-0.20 0.50 0.80 0.10 2;-0.50 0.20 0.10 0.60 2;-0.30 0.10 -0.05 0.20 2;-0.45 0.11 0.00 -0.32 3;-0.60 0.20 0.10 0.40 3; 0.80 -0.20 -0.20 0.50 4;-0.30 0.10 -0.05 0.20 4; 0.45 0.11 0.00 -0.32 1;-0.06 -0.18 0.62 0.20 1]
In this matrix I need to sum all rows containing a 1 in the last column, then the rows containing a 2 in the last column and so on with preserving the order of the data. To be more explicit the first sum is supposed to be row 1+2, second sum is row (3+4+5), third sum is row (6+7), fourth sum is row (8+9), and then the fifth sum which starts again with ones is row (10+11).
How can this be solved in MATLAB?
Many thanks for your help and support!
Best Answer