reshape函数作用:重塑数组,也就是对数组进行重新变形。
按列读取。
语法:A = reshape(A,m,n)或A = reshape(A,[m,n]) % 将A 的行列排列成m行n列
>> A=[1,2,3,4,5,6,7,8,9,10,11,12]
A =
1 2 3 4 5 6 7 8 9 10 11 12
>> B=reshape(A,2,6)
B =
1 3 5 7 9 11
2 4 6 8 10 12
>> B=reshape(A,4,3)
B =
1 5 9
2 6 10
3 7 11
4 8 12