Is there a better way to perform the following operation.
For example, for the following matrix:
A = 1 13 25 2 14 26 3 15 27 4 16 28 5 17 29 6 18 30 7 19 31 8 20 32 9 21 33 10 22 34 11 23 35 12 24 36
I am looking to transform to:
A_new = 1 13 25 2 14 26 3 15 27 2 14 26 3 15 27 4 16 28 3 15 27 4 16 28 5 17 29
Note, I am combining groups of three rows in a row for the entired matrix.
The following piece of code is already able to perform this. However, I have a huge matrix, and I believe there is an optimal way to do this. Also, I would like to play aroung with the number of rows to create the new matrix.
% Matrix A
A=1:36; A = reshape(A,12,3)j=1;for i=1:3 A_new(i,:) = [A(j,:) A(j+1,:) A(j+2,:)]; j = j +1;endA_new
Best Answer