%help查询reshape
>> help reshape
reshape - Reshape array
This MATLAB function reshapes A using the size vector, sz, to define size(B).
B = reshape(A,sz)
B = reshape(A,sz1,...,szN)
%B = reshape(A,m,n) 将矩阵A的元素返回到一个m×n的矩阵B
>> A=[1,2,3,4;5,6,7,8]
A =
1 2 3 4
5 6 7 8
>> B=reshape(A,2,4)
B =
1 2 3 4
5 6 7 8
>> B=reshape(A,1,8)
B =
1 5 2 6 3 7 4 8
>> B=reshape(A,1,[])
B =
1 5 2 6 3 7 4 8
B = reshape(A,m,n,p,…) or B =reshape(A,[m n p …]) 把A中元素进行重塑成m×n×p×…的矩阵,特别地,指定的维数m×n×p×…的积必须与prod(size(A))相同。
B = reshape(A,…,[],…) 指定某维数后,剩余的维数长度值用占位符[]来表示,使得维数的乘积等于prod(size(A))。prod(size(A))的值必须被指定维数的乘积平分。prod(size)的数目必须和prod(size(A))相同。