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

56 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-resize">Function resize <a href="#function-resize" title="Permalink">#</a></h1>
Resize a matrix
<h2 id="syntax">Syntax <a href="#syntax" title="Permalink">#</a></h2>
```js
math.resize(x, size)
math.resize(x, size, defaultValue)
```
<h3 id="parameters">Parameters <a href="#parameters" title="Permalink">#</a></h3>
Parameter | Type | Description
--------- | ---- | -----------
`x` | Array &#124; Matrix &#124; * | Matrix to be resized
`size` | Array &#124; Matrix | One dimensional array with numbers
`defaultValue` | number &#124; string | Zero by default, except in case of a string, in that case defaultValue = ' ' Default value: 0.
<h3 id="returns">Returns <a href="#returns" title="Permalink">#</a></h3>
Type | Description
---- | -----------
* &#124; Array &#124; Matrix | A resized clone of matrix `x`
<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
math.resize([1, 2, 3, 4, 5], [3]) // returns Array [1, 2, 3]
math.resize([1, 2, 3], [5], 0) // returns Array [1, 2, 3, 0, 0]
math.resize(2, [2, 3], 0) // returns Matrix [[2, 0, 0], [0, 0, 0]]
math.resize("hello", [8], "!") // returns string 'hello!!!'
```
<h2 id="see-also">See also <a href="#see-also" title="Permalink">#</a></h2>
[size](size.html),
[squeeze](squeeze.html),
[subset](subset.html),
[reshape](reshape.html)