Hello, everyone. Let's say I have a 6x6 matrix of random numbers like the one below (in green). I want to create two new matrices, one 3x6 (in blue) and the second 9x3 (in orange). (i) The first one (so the one in blue) must contain in the first row the sum per column of the row vectors 1 and 4 of the main matrix, in the second row the sum of the row vectors 2 and 5, and finally in the third and last row the sum of the row vectors 3 and 6. (ii) As for the second one (the one in orange), it must contain in the first column the sum per row of vectors in columns 1 and 4 of the main matrix, in the second row the sum of vectors in columns 2 and 5, and in the third row the sum of vectors in columns 3 and 6, including the cells of the first matrix in blue created previously. (iii) The two new matrices created must then be attached to the main matrix to create a new matrix of size 9x9.
Hoping to have described the problem well - I also attach an explanatory image to follow - how can I get the result as efficiently as possible.
Thank you very much to anyone who helps me,