reshape - Reshape array

from:http://www.mathworks.com/access/helpdesk/help/techdoc/ref/reshape.html

 

reshape - Reshape array

Syntax

B = reshape(A,m,n)
B = reshape(A,m,n,p,...)
B = reshape(A,[m n p ...])
B = reshape(A,...,[],...)
B = reshape(A,siz)

Description

B = reshape(A,m,n) returns the m -by-n matrix B whose elements are taken column-wise from A . An error results if A does not have m*n elements.

B = reshape(A,m,n,p,...) or B = reshape(A,[m n p ...]) returns an n-dimensional array with the same elements as A but reshaped to have the size m -by-n -by-p -by-... . The product of the specified dimensions, m*n*p* ..., must be the same as prod(size(A)) .

B = reshape(A,...,[],...) calculates the length of the dimension represented by the placeholder [] , such that the product of the dimensions equals prod(size(A)) . The value of prod(size(A)) must be evenly divisible by the product of the specified dimensions. You can use only one occurrence of [] .

B = reshape(A,siz) returns an n-dimensional array with the same elements as A , but reshaped to siz , a vector representing the dimensions of the reshaped array. The quantity prod(siz) must be the same as prod(size(A)) .

Examples

Reshape a 3 -by-4 matrix into a 2 -by-6 matrix.

A =
1 4 7 10
2 5 8 11
3 6 9 12

B = reshape(A,2,6)

B =
1 3 5 7 9 11
2 4 6 8 10 12
B = reshape(A,2,[])

B =
1 3 5 7 9 11
2 4 6 8 10 12
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值