MATLAB: Transpose a matrix within a matrix

MATLABmatrix transpose

I have a matrix that has X rows and 9 columns.
Each row is actually a 3×3 matrix.
I want to transpose all of those 3×3 matrixes. How can I do that?

Best Answer

Assuming that you obtain a 3x3 matrix from the k-th row of data with
Ak = reshape( data(k,:), 3, 3 ) ;
you can transpose all matrices in data as follows
data_t = data(:,[1 4 7 2 5 8 3 6 9]) ;