zeros
Create an array of all zeros
创建一个所有为零的阵列
Syntax
语法
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)
Description
描述
B = zeros(n) returns an n-by-n matrix of zeros. An error message appears if n is not a scalar.
B=zeros(n) 返回一个n-by-n 零矩阵。如果n不是一个标量,一个错误信息出现。
B = zeros(m,n) or B = zeros([m n]) returns an m-by-n matrix of zeros.
B=zeros(m,n)或B=zeros([m n]) 返回一个m-by-n 零矩阵。
B = zeros(d1,d2,d3...) or B = zeros([d1 d2 d3...]) returns an array of zeros with dimensions d1-by-d2-by-d3-by-... .
B=zeros(d1,d2,d3...)或B=zeros([d1 d2 d3...]) 返回一个零阵列带有维度d1-by-d2-by-d3-by-...。
B = zeros(size(A)) returns an array the same size as A consisting of all zeros.
B=zeros(size(A)) 返回一个与A尺寸相同的阵列包括所有零。
zeros(m, n,...,classname) or zeros([m,n,...],classname) is an m-by-n-by-... array of zeros of data type classname. classname is a string specifying the data type of the output. classname can have the following values: 'double', 'single', 'int8', 'uint8', 'int16', 'uint16', 'int32', or 'uint32'.
Zeros(m,n,...,classname) 或zeros([m,n,...],classname) 是一个m-by-n-by-..零阵列的数据类型classname。classname是一个规定输出特定数据类型。Classname 能够有下面的值:'double','single','int8', 'uint8', 'int16', 'uint16', 'int32',或'uint32'。
Example
例如
x = zeros(2,3,'int8');
Remarks
备注
The MATLAB language does not have a dimension statement; MATLAB automatically allocates storage for matrices. Nevertheless, for large matrices, MATLAB programs may execute faster if the zeros function is used to set aside storage for a matrix whose elements are to be generated one at a time, or a row or column at a time. For example
MATLAB语言没有维度语句;MATLAB自然而然的为矩阵分配存储。不过,长矩阵,MATLAB计划可以执行更快,如果zeros函数通常被用于调整旁边存储为一个矩阵它的元素是产生一个在当次,或者一列或行在当次。例如
x = zeros(1,n);
for i = 1:n, x(i) = i; end