REPEAT
(matrix, nrow, ncol) ;
The REPEAT function creates a matrix of repeated values.
The arguments to the REPEAT function are as follows:
is a numeric matrix or literal.
specifies the number of times matrix is repeated down rows.
specifies the number of times matrix is repeated across columns.
The REPEAT function creates a new matrix by repeating the values of the argument matrix nrow*ncol times: ncol times across the rows, and nrow times down the columns. The matrix argument can be numeric or character. For example, the following statements form a new matrix that consists of two vertical
and three horizontal copies of X
:
x = {1 2, 3 4}; y = repeat(x, 2, 3); print y;
Figure 23.280: Repeated Values
y | |||||
---|---|---|---|---|---|
1 | 2 | 1 | 2 | 1 | 2 |
3 | 4 | 3 | 4 | 3 | 4 |
1 | 2 | 1 | 2 | 1 | 2 |
3 | 4 | 3 | 4 | 3 | 4 |