## REPMAT Array Replication Function

Section: Array Generation and Manipulations

### Usage

The `repmat` function replicates an array the specified number of times. The source and destination arrays may be multidimensional. There are three distinct syntaxes for the `repmap` function. The first form:

      y = repmat(x,n)

replicates the array `x` on an `n-times-n` tiling, to create a matrix `y` that has `n` times as many rows and columns as `x`. The output `y` will match `x` in all remaining dimensions. The second form is

      y = repmat(x,m,n)

And creates a tiling of `x` with `m` copies of `x` in the row direction, and `n` copies of `x` in the column direction. The final form is the most general

      y = repmat(x,[m n p...])

where the supplied vector indicates the replication factor in each dimension.

### Example

Here is an example of using the `repmat` function to replicate a row 5 times. Note that the same effect can be accomplished (although somewhat less efficiently) by a multiplication.

    --> x = [1 2 3 4]

    x =

     1 2 3 4

    --> y = repmat(x,[5,1])

    y =

     1 2 3 4
     1 2 3 4
     1 2 3 4
     1 2 3 4
     1 2 3 4

    -->
    quit

The `repmat` function can also be used to create a matrix of scalars or to provide replication in arbitrary dimensions. Here we use it to replicate a 2D matrix into a 3D volume.

    --> x = [1 2;3 4]

    x =

     1 2
     3 4

    --> y = repmat(x,[1,1,3])

    y =

    (:,:,1) =

     1 2
     3 4

    (:,:,2) =

     1 2
     3 4

    (:,:,3) =

     1 2
     3 4

    -->
    quit