size
Sizes along all dimensions, or along one specific dimension.
Syntax
Section titled “Syntax”sz = size(X)n = size(X, dim)Description
Section titled “Description”With one argument, returns a row vector containing the size of X along each of its dimensions — first element is the row count, second is the column count, etc.
With two arguments, returns the size along the dimension dim only. dim is 1-based; passing a dim larger than ndims(X) raises an error.
Examples
Section titled “Examples”size(zeros(3,5)) % [3 5]size(zeros(3,5,2), 3) % 2size([1 2 3 4]) % [1 4]See also
Section titled “See also”length— Length of the longest dimension.numel— Total number of elements.ndims— Number of dimensions of the input.size_equal— Test whether all inputs share the same shape.