Function resize
Resize a matrix
Syntax
resize(x, size)
resize(x, size, defaultValue)
Parameters
Parameter |
Type |
Description |
x |
Array | Matrix | * |
Matrix to be resized |
size |
Array | Matrix |
One dimensional array with numbers |
defaultValue |
number | string |
Zero by default, except in case of a string, in that case defaultValue = ' ' Default value: 0. |
Returns
Type |
Description |
* | Array | Matrix |
A resized clone of matrix x |
Examples
resize([1, 2, 3, 4, 5], [3]); // returns Array [1, 2, 3]
resize([1, 2, 3], [5], 0); // returns Array [1, 2, 3, 0, 0]
resize(2, [2, 3], 0); // returns Matrix [[2, 0, 0], [0, 0, 0]]
resize("hello", [8], "!"); // returns string 'hello!!!'
See also
size,
squeeze,
subset