Y = zeros(n)
Y = zeros(m,n)
Y = zeros(size(A))
Y = zeros(n)is an
nmatrix of zeros.
Y = zeros(m,n) is an
n matrix of zeros.
Y = zeros(size(A)) is the same size as
A and consists of all zeros.
The MATLAB language does not have a dimension statement and MATLAB automatically allocates storage for matrices. Nevertheless, most MATLAB programs 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.
n = 1000, the
takes about 1.2 seconds to execute on a Sun SPARC-1. If the loop is preceded by the statement
for i = 1:n, x(i) = i; end
the computations require less than 0.2 seconds.
x = zeros(1,n);
(c) Copyright 1994 by The MathWorks, Inc.