how reshape this matrix in matlab? thx

6 views (last 30 days)
I have this matrix: for example:
into:
how can I do it without using loop? can mat2cell be useful in this case?
many thanks!!
  1 Comment
Stephen23
Stephen23 on 4 Jan 2015
Edited: Stephen23 on 4 Jan 2015
Try the transpose operator: given a matrix X, then the transpose is X.'

Sign in to comment.

Accepted Answer

Matt J
Matt J on 4 Jan 2015
Edited: Matt J on 4 Jan 2015
If the 3x3 blocks are symmetric, as in your example, a simple transpose is all you need. If, more generally, they are not, however,I would recommend MAT2TILES ( Download ) as follows
C=mat2tiles(YourMatrix,[3,3]);
YourMatrixReshaped = cell2mat(C.')
  1 Comment
Stephen23
Stephen23 on 4 Jan 2015
Mathematically correct, but it probably would be still best to introduce beginners to the nonconjugate transpose: .'

Sign in to comment.

More Answers (1)

the cyclist
the cyclist on 4 Jan 2015
Edited: the cyclist on 4 Jan 2015
If your original matrix is A, then transpose it:
B = A'
[This is actually the complex conjugate transpose, but assuming your matrix is real, that's OK. You can read more with "doc transpose" and "doc ctranspose".]

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!