Skip to content

ndims

Number of dimensions of the input.

n = ndims(A)

Returns the dimensionality of A. Scalars and vectors report 2 (MathJet treats them as 1×N or N×1 matrices, like MATLAB). Higher-dimensional arrays report their actual dimension count.

ndims(7) % 2
ndims([1 2 3]) % 2
ndims(zeros(3,4,5)) % 3
  • size — Sizes along all dimensions, or along one specific dimension.
  • length — Length of the longest dimension.
  • numel — Total number of elements.