# coyote: REPMAT

- coyote/Utilities
- [Source code]

NAME

      REPMAT

PURPOSE

      This program replicates a matrix or array in the style of
      the MATLAB RebMat command. The matrix or array is "tiled"
      in some integer number of columns and rows.

AUTHOR

      FANNING SOFTWARE CONSULTING
      David Fanning, Ph.D.
      1645 Sheely Drive
      Fort Collins, CO 80526 USA
      Phone: 970-221-0438
      E-mail: david@idlcoyote.com
      Coyote's Guide to IDL Programming: http://www.idlcoyote.com

CATEGORY

      Utilities

CALLING SEQUENCE

      tiledMatrix = RepMat(matrix, ncol, nrow)

AUGUMENTS

      matix:         The matrix or array to be tiled.
      ncol:          The number of columns in the tile.
      nrow:          The number of rows in the tile.

RETURN_VALUE

      tiledMatrix:    If (xdim,ydim) is the size of the original 2D matrix, then the
                      output matrix is sized (ncol*xdim, nrow*ydim).

KEYWORDS

      None.

EXAMPLE

      IDL> matrix = Reform(Indgen(6) + 1, 3, 2)
      IDL> Print, matrix, FORMAT='(3I3)'
           1  2  3
           4  5  6
      IDL> Print, RepMat(matrix, 3, 2), FORMAT='(9I3)'
           1  2  3  1  2  3  1  2  3
           4  5  6  4  5  6  4  5  6
           1  2  3  1  2  3  1  2  3
           4  5  6  4  5  6  4  5  6

MODIFICATION HISTORY

      Written by David W. Fanning, 8 May 2009.
      Algorithm significantly improved by Ronn Kling, 4 August 2009.
      Added line to handle an input matrix with a trailing 1 dimension correctly. DJ 8 March 2011.