Skip to main content

5.6) Basic Array Information


A number of useful functions provide information on arrays.

  • size - Returns the length of each dimension of an array, as a row vector
  • Syntax: d=size(A) or [x y]=size(A) or [x y z]=size(A), etc. If "A" is a scalar then size(A) gives a 1x1 vector

  • length - Returns the length of the longest dimension of an array
  • Syntax: d=length(A), where "d" is a scalar

  • ndims - Returns the number of dimensions of an array
  • Syntax: d=ndims(A), where "d" is a scalar

  • numel - Returns the number of elements in an array. For example, if an array has dimensions AxBxC, then numel will return the product ABC
  • Syntax: d=numel(A), where "d" is a scalar

  • isempty - Returns 1 (true) if the array is empty
  • Syntax: d=isempty(A), where "d" is logical (0 or 1)

  • isequal - Returns 1 (true) if the two input arrays are equal (in both size and cell values)
  • Syntax: d=isequal(A,B), where "d" is a logical (0 or 1)