2022-03-01 13:04:09 +01:00

61 lines
1.6 KiB
Markdown

---
layout: default
---
<!-- Note: This file is automatically generated from source code comments. Changes made in this file will be overridden. -->
<h1 id="function-concat">Function concat <a href="#function-concat" title="Permalink">#</a></h1>
Concatenate two or more matrices.
<h2 id="syntax">Syntax <a href="#syntax" title="Permalink">#</a></h2>
```js
math.concat(A, B, C, ...)
math.concat(A, B, C, ..., dim)
```
<h3 id="where">Where <a href="#where" title="Permalink">#</a></h3>
- `dim: number` is a zero-based dimension over which to concatenate the matrices.
By default the last dimension of the matrices.
<h3 id="parameters">Parameters <a href="#parameters" title="Permalink">#</a></h3>
Parameter | Type | Description
--------- | ---- | -----------
`args` | ... Array &#124; Matrix | Two or more matrices
<h3 id="returns">Returns <a href="#returns" title="Permalink">#</a></h3>
Type | Description
---- | -----------
Array &#124; Matrix | Concatenated matrix
<h3 id="throws">Throws <a href="#throws" title="Permalink">#</a></h3>
Type | Description
---- | -----------
<h2 id="examples">Examples <a href="#examples" title="Permalink">#</a></h2>
```js
const A = [[1, 2], [5, 6]]
const B = [[3, 4], [7, 8]]
math.concat(A, B) // returns [[1, 2, 3, 4], [5, 6, 7, 8]]
math.concat(A, B, 0) // returns [[1, 2], [5, 6], [3, 4], [7, 8]]
math.concat('hello', ' ', 'world') // returns 'hello world'
```
<h2 id="see-also">See also <a href="#see-also" title="Permalink">#</a></h2>
[size](size.html),
[squeeze](squeeze.html),
[subset](subset.html),
[transpose](transpose.html)