Changing the order of matrix in Matlab

Can anyone help me with a code to change the order of a given matrix. For example given the following matrix:

$\displaystyle \begin{pmatrix}1&2&3&4\\5&6&7&8\end{pmatrix}$

I want the function to change the order to:

$\displaystyle \begin{pmatrix}3&4&1&2\\7&8&5&6\end{pmatrix}$

The matrix is basically being divided into frames. I guess you can find the number of frames by dividing the number of columns by number of rows. So for this matrix it would be 2 frames.

I can only manage to get the first frame.

Re: Changing the order of matrix in Matlab

- function rewind(F)
- [m,n]=size(F);
- frames=n/m; %Number of frames
- C=[];
- for i=1:frames,
- B=F(:,(m*(i-1))+1:m*i);
- C=[B C];
- end
- C