Skip to content

zeros

Array of all zeros.

B = zeros % scalar 0
B = zeros(n) % n×n square
B = zeros(m, n) % m×n
B = zeros(d1, d2, d3, ...)
B = zeros([d1 d2 …])
B = zeros(…, classname)

Creates an array of all zeros with the given dimensions. With no arguments, returns the scalar 0. With one positive integer, returns an n×n square; with two or more, builds an N-dimensional array. The optional last string argument selects the element type — 'int32', 'single', 'double', 'longdouble' — defaulting to the interpreter’s default precision.

zeros(3) % 3×3 zeros
zeros(2, 4) % 2×4 zeros
zeros(2, 3, 'int32') % 2×3 int32 zeros
  • ones — Array of all ones.
  • eye — Identity matrix.
  • true — Logical array of all true.
  • false — Logical array of all false.
  • nan — Array of NaN values.
  • inf — Array of Inf values.