Previous: Cell Arrays, Up: Data Containers [Contents][Index]
Comma separated lists 2 are the basic argument type to all Octave functions - both for input and return arguments. In the example
max (a, b)
‘a, b’ is a comma separated list. Comma separated lists can appear on both the right and left hand side of an assignment. For example
x = [1 0 1 0 0 1 1; 0 0 0 0 0 0 7]; [i, j] = find (x, 2, "last");
Here, ‘x, 2, "last"’ is a comma separated list constituting
the input arguments of find
. find
returns a comma
separated list of output arguments which is assigned element by
element to the comma separated list ‘i, j’.
Another example of where comma separated lists are used is in the
creation of a new array with []
(see Matrices) or the
creation of a cell array with {}
(see Basic Usage of Cell Arrays). In the expressions
a = [1, 2, 3, 4]; c = {4, 5, 6, 7};
both ‘1, 2, 3, 4’ and ‘4, 5, 6, 7’ are comma separated lists.
Comma separated lists cannot be directly manipulated by the user. However, both structure arrays and cell arrays can be converted into comma separated lists, and thus used in place of explicitly written comma separated lists. This feature is useful in many ways, as will be shown in the following subsections.
Previous: Cell Arrays, Up: Data Containers [Contents][Index]