Concatenation Operator, Vertical: // |
The vertical concatenation operator (//) produces a new matrix by vertically joining matrix1 and matrix2. The matrices must have the same number of columns, which is also the number of columns in the new matrix. The number of rows in the new matrix is the number of rows in matrix1 plus the number of rows in matrix2.
For example, the following statements produce the matrix c, shown in Figure 23.6:
a = {1 1 1, 7 7 7}; b = {0 0 0, 8 8 8}; c = a//b; print c;
c | ||
---|---|---|
1 | 1 | 1 |
7 | 7 | 7 |
0 | 0 | 0 |
8 | 8 | 8 |
For character matrices, the element size of the result matrix is the larger of the element sizes of the two operands, as shown in Figure 23.7:
d = {"AB" "CD", "EF" "GH"}; e = {"I" "J", "K" "L", "M" "N"}; f = d//e; print f;
f | |
---|---|
AB | CD |
EF | GH |
I | J |
K | L |
M | N |
You can use the vertical concatenation operator when one of the arguments has not been assigned a value. For example, if X has not been defined and Y is a matrix, X//Y results in a new matrix equal to Y.