concat

concat(A, B, C, ...)

concat(A, B, C, ..., dim)

Try it yourself:


Join arrays and matrices with concat

concat(A, B, C, ...) combines compatible arrays or matrices along their first dimension. It is a practical way to assemble data in stages: append rows to a table, join vectors, or build one matrix from several blocks.

Typical uses

Concatenating [1, 2] and [3, 4] produces a longer sequence. With two-dimensional inputs, it appends row blocks, so their column shapes must agree. To construct a matrix explicitly from row vectors, matrixFromRows communicates the intent especially well; matrixFromColumns is the column-oriented counterpart.

Shape matters

Before concatenating matrices, inspect them with size. A 2-by-3 matrix cannot be stacked with a 1-by-2 matrix because the column counts differ. If the data is nested more deeply than expected, flatten can turn it into a one-dimensional list, although it changes the structure rather than repairing an incompatible matrix shape.

Preparing and following up

Use reshape to reorganize a compatible collection before concatenation, or resize when a deliberate target shape and padding policy are needed. Afterwards, subset can select rows or values from the combined result. Keep numeric and text values consistent when downstream matrix operations are expected.

All functions