Create an array of all 0 elements
Grammar
B = Zeros (n)
B = Zeros (m,n)
B = Zeros ([M n])
B = Zeros (D1,d2,d3 ...)
B = Zeros ([D1 d2 D3 ...])
B = zeros (Size (A))
Zeros (m, n,..., classname)
Zeros ([M,n,...],classname)
Describe
1, B = Zeros (n) returns a 0 matrix of n x N. If n is not a scalar, an error is thrown.
2, B = Zeros (m,n) or B = zeros ([m n]) returns a 0 matrix of M x N.
3, B = Zeros (d1,d2,d3 ...) or b = Zeros ([D1 d2 D3 ...]) returns a d1-by-d2-by-d3-by-.... An array of 0 elements.
4, B = zeros (Size (A)) returns a zero group that is the same size as a.
5, Zeros (m, n,..., classname) or zeros ([M,n,...] Returns a type of classname m x N x ... Zero Group. ClassName can be some of the following values: Double ', ' single ', ' int8 ', ' uint8 ', ' int16 ', ' UInt16 ', ' int32 ', or ' uint32 '
Example
x = zeros (2,3, ' int8 ');
Note
The MATLAB language does not have a dimension declaration; matlab automatically allocates storage space for the matrix. However, for large matrices, the MATLAB program may execute faster if the 0 function is used to set a matrix, its elements will be generated once, or the rows or columns of time reserve storage space. For example
x = zeros (1,n);
For i = 1:n, x (i) = i; End
The zeros function in MATLAB