UNPKG

1.08 kBMarkdownView Raw
1<!-- Note: This file is automatically generated from source code comments. Changes made in this file will be overridden. -->
2
3# Function resize
4
5Resize a matrix
6
7
8## Syntax
9
10```js
11math.resize(x, size)
12math.resize(x, size, defaultValue)
13```
14
15### Parameters
16
17Parameter | Type | Description
18--------- | ---- | -----------
19`x` | Array &#124; Matrix &#124; * | Matrix to be resized
20`size` | Array &#124; Matrix | One dimensional array with numbers
21`defaultValue` | number &#124; string | Zero by default, except in case of a string, in that case defaultValue = ' ' Default value: 0.
22
23### Returns
24
25Type | Description
26---- | -----------
27* &#124; Array &#124; Matrix | A resized clone of matrix `x`
28
29
30## Examples
31
32```js
33math.resize([1, 2, 3, 4, 5], [3]) // returns Array [1, 2, 3]
34math.resize([1, 2, 3], [5], 0) // returns Array [1, 2, 3, 0, 0]
35math.resize(2, [2, 3], 0) // returns Matrix [[2, 0, 0], [0, 0, 0]]
36math.resize("hello", [8], "!") // returns string 'hello!!!'
37```
38
39
40## See also
41
42[size](size.md),
43[squeeze](squeeze.md),
44[subset](subset.md),
45[reshape](reshape.md)