---
layout: default
---
Function flatten #
Flatten a multidimensional matrix into a single dimensional matrix.
A new matrix is returned, the original matrix is left untouched.
Syntax #
```js
math.flatten(x)
```
Parameters #
Parameter | Type | Description
--------- | ---- | -----------
`x` | Matrix | Array | Matrix to be flattened
Returns #
Type | Description
---- | -----------
Matrix | Array | Returns the flattened matrix
Throws #
Type | Description
---- | -----------
Examples #
```js
math.flatten([[1,2], [3,4]]) // returns [1, 2, 3, 4]
```
See also #
[concat](concat.html),
[resize](resize.html),
[size](size.html),
[squeeze](squeeze.html)