Reputation: 3
If I have a matrix as such:
a= [90,23,0,91,24,0,92,35,0]
And I would like to break the matrix as shown below:
a= [90,23,0;
91,24,0;
92,35,0]
Is there any way of doing that? I have very long matrices which need to broken up as such.
Upvotes: 0
Views: 58
Reputation: 3832
The function reshape()
may help
a = reshape(a,[],3)'
If matrix is complex, it is better to use the operation .'
a = reshape(a,[],3).'
in order to avoid complex conjugation
Upvotes: 1
Reputation: 513
You can use reshape(a,[3,3])
to turn your array into a 3x3 matrix, and then for your specific order you can transpose it: reshape(a,[3,3])'
Upvotes: 2