how reshape this matrix in matlab? thx
2 views (last 30 days)
Show older comments
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
Accepted Answer
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
on 4 Jan 2015
Mathematically correct, but it probably would be still best to introduce beginners to the nonconjugate transpose: .'
More Answers (1)
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".]
0 Comments
See Also
Categories
Find more on Resizing and Reshaping Matrices in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!