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.
• Comma Separated Lists Generated from Cell Arrays: |
• Comma Separated Lists Generated from Structure Arrays: |
Comma-separated lists are also sometimes informally referred to as cs-lists.
© 1996–2018 John W. Eaton
Permission is granted to make and distribute verbatim copies of this manual provided the copyright notice and this permission notice are preserved on all copies.
Permission is granted to copy and distribute modified versions of this manual under the conditions for verbatim copying, provided that the entire resulting derived work is distributed under the terms of a permission notice identical to this one.Permission is granted to copy and distribute translations of this manual into another language, under the above conditions for modified versions.
https://octave.org/doc/interpreter/Comma-Separated-Lists.html