GNU Octave Manual Version 3by John W. Eaton, David Bateman, Søren Hauberg Paperback (6"x9"), 568 pages ISBN 095461206X RRP £24.95 ($39.95) |

## 3.2 Object Sizes

The following functions allow you to determine the size of a variable or
expression. These functions are defined for all objects. They return
-1 when the operation doesn't make sense. For example, Octave's
data structure type doesn't have rows or columns, so the `rows`

and
`columns`

functions return -1 for structure arguments.

__Built-in Function:__**ndims***(*`a`)- Returns the number of dimensions of array
`a`. For any array, the result will always be larger than or equal to 2. Trailing singleton dimensions are not counted.

__Built-in Function:__**columns***(*`a`)- Return the number of columns of
`a`.See also size, numel, rows, length, isscalar, isvector, and ismatrix

__Built-in Function:__**rows***(*`a`)- Return the number of rows of
`a`.See also size, numel, columns, length, isscalar, isvector, ismatrix

__Built-in Function:__**numel***(*`a`)- Returns the number of elements in the object
`a`.See also size

__Built-in Function:__**length***(*`a`)- Return the `length' of the object
`a`. For matrix objects, the length is the number of rows or columns, whichever is greater (this odd definition is used for compatibility with Matlab).

__Built-in Function:__**size***(*`a`,`n`)- Return the number rows and columns of
`a`.With one input argument and one output argument, the result is returned in a row vector. If there are multiple output arguments, the number of rows is assigned to the first, and the number of columns to the second, etc. For example,

size ([1, 2; 3, 4; 5, 6]) => [ 3, 2 ] [nr, nc] = size ([1, 2; 3, 4; 5, 6]) => nr = 3 => nc = 2

If given a second argument,

`size`

will return the size of the corresponding dimension. For examplesize ([1, 2; 3, 4; 5, 6], 2) => 2

returns the number of columns in the given matrix.

See also numel

__Built-in Function:__**isempty***(*`a`)- Return 1 if
`a`is an empty matrix (either the number of rows, or the number of columns, or both are zero). Otherwise, return 0.

__Built-in Function:__**sizeof***(*`val`)- Return the size of
`val`in bytes

__Built-in Function:__**size_equal***(*`a`,`b`, ...)- Return true if the dimensions of all arguments agree.
Trailing singleton dimensions are ignored.
See also size, numel

__Built-in Function:__**squeeze***(*`x`)- Remove singleton dimensions from
`x`and return the result. Note that for compatibility with Matlab, all objects have a minimum of two dimensions and row vectors are left unchanged.

ISBN 095461206X | GNU Octave Manual Version 3 | See the print edition |