# matrixFromRows() Function & Examples

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

## matrixFromRows

#### matrixFromRows(...arr)

#### matrixFromRows(row1, row2)

#### matrixFromRows(row1, row2, row3)

Try it yourself:

```calculio
matrixFromRows([1, 2, 3], [[4],[5],[6]])
```

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

---

## Build a matrix from rows

**matrixFromRows** constructs a matrix by treating each supplied vector or array as one row. It is ideal when observations, equations, or records are already written horizontally.

## Example

Rows `[1,2]` and `[3,4]` form a 2-by-2 matrix. Use [matrixFromColumns](https://calcul.io/function/matrixFromColumns/index.md) when your inputs are features stored as columns. [transpose](https://calcul.io/function/transpose/index.md) exchanges the two viewpoints.

## Compatibility

All rows must have the same length for a rectangular matrix. Verify dimensions with [size](https://calcul.io/function/size/index.md) before using [multiply](https://calcul.io/function/multiply/index.md) or a solver. [concat](https://calcul.io/function/concat/index.md) can append compatible row blocks, but matrixFromRows is clearer at construction time.

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