# zeros

## Purpose

All zeros.

## Synopsis

    Y = zeros(n)
    Y = zeros(m,n)
    Y = zeros(size(A))

## Description

`Y = zeros(n)` is an `n`-by-`n` matrix of zeros.

`Y = zeros(m,n)` is an `m`-by-`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.

## Examples

With `n = 1000`, the `for` loop

     for i = 1:n, x(i) = i; end

takes about 1.2 seconds to execute on a Sun SPARC-1. If the loop is preceded by the statement

     x = zeros(1,n);

the computations require less than 0.2 seconds.

## See Also

    eye, ones, rand, randn

(c) Copyright 1994 by The MathWorks, Inc.