Function resize #
调整矩阵大小
Syntax #
math.resize(x, size)
math.resize(x, size, defaultValue)
Parameters #
| Parameter | Type | Description |
|---|---|---|
x |
Array | Matrix | * | 要调整大小的矩阵 |
size |
Array | Matrix | 包含数字的一维数组 |
defaultValue |
number | string | 默认为0,除非是字符串,在这种情况下defaultValue = ‘ ‘。默认值:0。 |
Returns #
| Type | Description |
|---|---|
| * | Array | Matrix | 矩阵 x 的调整大小后的副本 |
Throws #
Type | Description —- | ———–
Examples #
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!!!'