Skip to content

numel

Total number of elements.

n = numel(A)

Returns the total element count of A — the product of all dimension sizes. Equivalent to prod(size(A)). For an empty array, returns 0.

The MATLAB-compatible indexed form numel(A, idx1, idx2, ...) is reserved but currently raises a runtime error.

numel([1 2 3 4]) % 4
numel(zeros(3,5)) % 15
numel([]) % 0
  • size — Sizes along all dimensions, or along one specific dimension.
  • length — Length of the longest dimension.
  • ndims — Number of dimensions of the input.
  • isempty — Test whether the input has zero elements.