From: http://hi.baidu.com/lingyin55/blog/item/252144f27e6bfe16b07ec587.html/cmtid/e68dc9c6085e7c159c163d47
Reshape changes the shape of the specified matrix, but the number of elements remains unchanged,
For example, row vectors:
A = [1 2 3 4 5 6]
Execute the following statement to convert it into three rows and two columns:
B = reshape (A, 3, 2)
Execution result:
B =
1 4
2 5
3 6
If a = [1 2 3
4 5 6
7 8 9]
Use reshpe to get B = [1 2 3 4 5 6 7 8 9]
You only need to transpose:
B = reshape (A', 1, 9)
----------------------------------------------
The MATLAB interpretation is as follows:
Reshape change size.
Reshape (x, m, n) returns the M-by-n matrix whose elements
Are taken columnwise from X. An error results if X does
Not have M * n elements.
Reshape (x, M, N, P,...) returns an N-D array with the same
Elements as X but reshaped to have the size M-by-n-by-p--...
M * n * p *... must be the same as prod (SIZE (x )).
Reshape (x, [m n p...]) is the same thing.
Reshape (x,..., [],...) calculates the length of the dimension
Represented by [], such that the product of the dimensions
Equals prod (SIZE (x). Prod (SIZE (x) must be evenly divisible
By the product of the known dimensions. You can use only one
Occurrence of [].
In general, reshape (x, siz) returns an N-D array with the same
Elements as X but reshaped to the size siz. Prod (siz) must be
The same as prod (SIZE (x )).