MATLAB reshape Function

Source: Internet
Author: User
Syntax

(1) B = reshape (a, m, n)

Usage:
B = reshape (a, m, n) returns M * n matrix B. Its element is to get the row width of. If a does not have an M * nelement, an error is returned.

Example:

<span style="font-size:18px;">>> A=rand(1,10)</span>
Result:

<span style="font-size:18px;">A =  Columns 1 through 8    0.1622    0.7943    0.3112    0.5285    0.1656    0.6020    0.2630    0.6541  Columns 9 through 10    0.6892    0.7482</span>

<span style="font-size:18px;">>> B=reshape(A,5,2)</span>
Result:
B =    0.1622    0.6020    0.7943    0.2630    0.3112    0.6541    0.5285    0.6892    0.1656    0.7482

(2)

B = reshape (A, M, N, P ,...)

B = reshape (A, [m n p...])
Returns an n-dimensional array with the same elements as a, but its structure changes to M * n * p *...

For example:

<span style="font-size:18px;">>> A=rand(1,12)</span>
Result: matrix
A =  Columns 1 through 8    0.4505    0.0838    0.2290    0.9133    0.1524    0.8258    0.5383    0.9961  Columns 9 through 12    0.0782    0.4427    0.1067    0.9619

>> D=reshape(A,2,3,2)D(:,:,1) =    0.4505    0.2290    0.1524    0.0838    0.9133    0.8258D(:,:,2) =    0.5383    0.0782    0.1067    0.9961    0.4427    0.9619

(3)

B = reshape (A,..., [],...)

>> C=reshape(A,5,[])
Result:

C =    0.1622    0.6020    0.7943    0.2630    0.3112    0.6541    0.5285    0.6892    0.1656    0.7482

(4)

B = reshape (A, siz)

Returns an n-dimensional array with the same elements as a. however, according to siz, a vector transformed array dimension. The value prod (siz) must be the same as prod (SIZE (.

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.