reshape函数

来源:互联网 发布:人脸变漫画软件 编辑:程序博客网 时间:2024/05/18 08:21

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) 返回m-by-n矩阵B,它的元素是获得A的行宽度。如果A没有m*n元素,得到一个错误结果。

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,m,n,p,...) B=reshape(A,[m n p ...]) 返回一个与A元素相同的n维阵列但是改造了尺寸m-by-n-by-p-by-...。产生特定的维度,m*n*p...,必须是一般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 occurence of [].

B=reshape(A,...,[],...) 计算维度的长度,通过位置容器[]表示。满足的条件是维度的值等于prod(size(A))Prod(size(A))的值必须通过特定维度的值平分。你仅仅能够使用一次[]

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)).

B=reshape(A,siz) 返回一个与A相同元素的n维阵列,但是改造依据siz,一个向量改造改造的阵列的维度。数值prod(siz)必须和prod(size(A))相同。

Examples

例如

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

改造一个3-by-4矩阵为一个2-by-6 矩阵。

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

原创粉丝点击