J Function |
The J function creates a matrix with nrow rows and ncol columns with all elements equal to value.
The arguments to the J function are as follows:
is a numeric matrix or literal that contains the number of rows.
is a numeric matrix or literal that contains the number of columns.
is a numeric or character matrix or literal for filling the rows and columns of the matrix.
If ncol is not specified, it defaults to nrow. If value is not specified, it defaults to 1. The REPEAT and SHAPE functions can also perform this operation, and they are more general.
Examples of the J function are as follows:
b = j(3, 4); c = j(5, 2, "xyz"); print b, c;
b | |||
---|---|---|---|
1 | 1 | 1 | 1 |
1 | 1 | 1 | 1 |
1 | 1 | 1 | 1 |
c | |
---|---|
xyz | xyz |
xyz | xyz |
xyz | xyz |
xyz | xyz |
xyz | xyz |