Node:Object Sizes, Previous:User-defined Data Types, Up:Data Types
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.
columns (a) | Function File |
Return the number of columns of a. |
rows (a) | Function File |
Return the number of rows of a. |
length (a) | Built-in Function |
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). |
size (a, n) | Built-in Function |
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 ([1, 2; 3, 4; 5, 6], 2) => 2 returns the number of columns in the given matrix. |
isempty (a) | Built-in Function |
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. |