How to reorganize the contents of an array/matrix in Matlab?
Use 'reshape' command in Matlab.
>> help reshape
Example:
>> ss = magic(4)
ss =
16 2 3 13
5 11 10 8
9 7 6 12
4 14 15 1
>> d = reshape(ss,8,2)
d1 =
16 3
5 10
9 6
4 15
2 13
11 8
7 12
14 1
>> d2 = reshape(ss,2,8)
d2 =
16 9 2 7 3 6 13 12
5 4 11 14 10 15 8 1
Note: reshape works 'COLUMN' wise.
No comments:
Post a Comment