I have a 2D matrix where the № of columns is always a multiple of 3 (e.g. 250×27
) - due to a repeating organisation of the results (A,B,C
, A,B,C
, A,B,C
, and so forth). I wish to reshape this matrix to create a new matrix with 3 columns - each containing the aggregated data for each type (A,B,C
) (e.g. 2250×3
).
So in a matrix of 250×27
, all the data in columns 1,4,7,10,13,16,19,22,25
would be merged to form the first column of the resulting reshaped matrix.
The second column in the resulting reshaped matrix would contain all the data from columns 2,5,8,11,14,17,20,23,26
- and so forth.
Is there a simple way to do this in MATLAB? I only know how to use reshape
if the columns I wanted to merge were adjacent (1,2,3,4,5,6
) rather than non-adjacent (1,4,7,10,13,16
) etc.