# concat() Function & Examples

Use the concat() matrix function in Calcul.io. Review its syntax, edit working examples, understand the result, and explore related math functions.

## concat

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

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

Try it yourself:

```calculio
A = [1, 2; 5, 6]
B = [3, 4; 7, 8]
concat(A, B)
concat(A, B, 1)
concat(A, B, 2)
```

[det](https://calcul.io/function/det/index.md)

[diag](https://calcul.io/function/diag/index.md)

[identity](https://calcul.io/function/identity/index.md)

[inv](https://calcul.io/function/inv/index.md)

[ones](https://calcul.io/function/ones/index.md)

[range](https://calcul.io/function/range/index.md)

[size](https://calcul.io/function/size/index.md)

[squeeze](https://calcul.io/function/squeeze/index.md)

[subset](https://calcul.io/function/subset/index.md)

[trace](https://calcul.io/function/trace/index.md)

[transpose](https://calcul.io/function/transpose/index.md)

[zeros](https://calcul.io/function/zeros/index.md)

---

## 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](https://calcul.io/function/matrixFromRows/index.md) communicates the intent especially well; [matrixFromColumns](https://calcul.io/function/matrixFromColumns/index.md) is the column-oriented counterpart.

## Shape matters

Before concatenating matrices, inspect them with [size](https://calcul.io/function/size/index.md). 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](https://calcul.io/function/flatten/index.md) 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](https://calcul.io/function/reshape/index.md) to reorganize a compatible collection before concatenation, or [resize](https://calcul.io/function/resize/index.md) when a deliberate target shape and padding policy are needed. Afterwards, [subset](https://calcul.io/function/subset/index.md) can select rows or values from the combined result. Keep numeric and text values consistent when downstream matrix operations are expected.

[All functions](https://calcul.io/functions/index.md)
