Repmat:replicate and tile an array

Source: Internet
Author: User

Repmat:replicate and tile an array

Syntax

B = Repmat (a,m,n)

B = Repmat (a,[m n])

B = Repmat (a,[m n p ...])

Description

b = Repmat (a,m,n) creates a large matrix B consisting of an m-by-n tiling of copies of a. The size of B is [size (a,1) *m, (Size (a,2) *n]. The statement Repmat (A,N) creates an n-by-n tiling.

B = Repmat (a,[m n]) accomplishes the same result as Repmat (A,m,n).

B = repmat (A,[m n p ...])  produces a multidimensional array b composed of copies of a .  the size of b is [size (a,1) *m, size (a,2) *n, size (A,3) *p,  ...].  

Repmat (A,m,n) when a was a scalar, produces an m-by-n matrix filled with a ' s value and have A's class. For certain values, you can achieve the same results using other functions, as shown by the following Examples:repmat (NaN , m,n) returns the same result as NaN (M,n). Repmat (single (INF), m,n) are the same as INF (M,n, ' single '). Repmat (int8 (0), m,n) is the same as zeros (M,n, ' int8 '). Repmat (UInt32 (1), m,n) is the same as ones (M,n, ' UInt32 '). Repmat (Eps,m,n) is the same as EPS (Ones (M,n)).

Examples

In this example, Repmat replicates copies of the Second-order identity matrix, resulting in a "checkerboard" pattern.

B = Repmat (eye (2), 3,4)%size (eye (2), 1) = 2; Size (eye (2), 2) = 2;

B =% (3*2;4*2;) eye (2) whole to right becomes 8; down to 6

1 0 1 0 1 0 1 0

0 1 0 1 0 1 0 1

1 0 1 0 1 0 1 0

0 1 0 1 0 1 0 1

1 0 1 0 1 0 1 0

0 1 0 1 0 1 0 1

The statement N = Repmat (nan,[2 3]) creates a 2-by-3 matrix of NaNs.

Repmat:replicate and tile an array

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.