Function zeros
Create a matrix filled with zeros. The created matrix can have one or
multiple dimensions.
Syntax
zeros(m)
zeros(m, format)
zeros(m, n)
zeros(m, n, format)
zeros([m, n])
zeros([m, n], format)
Parameters
Parameter |
Type |
Description |
size |
...number | Array |
The size of each dimension of the matrix |
format |
string |
The Matrix storage format |
Returns
Type |
Description |
Array | Matrix |
A matrix filled with zeros |
Examples
zeros(3); // returns [0, 0, 0]
zeros(3, 2); // returns [[0, 0], [0, 0], [0, 0]]
zeros(3, 'dense'); // returns [0, 0, 0]
var A = [[1, 2, 3], [4, 5, 6]];
zeros(size(A)); // returns [[0, 0, 0], [0, 0, 0]]
See also
ones,
eye,
size,
range