Use MATLAB reshape

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.