<html lang="en"> <head> <title>Comma Separated Lists - Untitled</title> <meta http-equiv="Content-Type" content="text/html"> <meta name="description" content="Untitled"> <meta name="generator" content="makeinfo 4.13"> <link title="Top" rel="start" href="index.html#Top"> <link rel="up" href="Data-Containers.html#Data-Containers" title="Data Containers"> <link rel="prev" href="Cell-Arrays.html#Cell-Arrays" title="Cell Arrays"> <link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage"> <meta http-equiv="Content-Style-Type" content="text/css"> <style type="text/css"><!-- pre.display { font-family:inherit } pre.format { font-family:inherit } pre.smalldisplay { font-family:inherit; font-size:smaller } pre.smallformat { font-family:inherit; font-size:smaller } pre.smallexample { font-size:smaller } pre.smalllisp { font-size:smaller } span.sc { font-variant:small-caps } span.roman { font-family:serif; font-weight:normal; } span.sansserif { font-family:sans-serif; font-weight:normal; } --></style> </head> <body> <div class="node"> <a name="Comma-Separated-Lists"></a> <p> Previous: <a rel="previous" accesskey="p" href="Cell-Arrays.html#Cell-Arrays">Cell Arrays</a>, Up: <a rel="up" accesskey="u" href="Data-Containers.html#Data-Containers">Data Containers</a> <hr> </div> <h3 class="section">6.3 Comma Separated Lists</h3> <p><a name="index-comma-separated-lists-410"></a><a name="index-cs_002dlists-411"></a> Comma separated lists <a rel="footnote" href="#fn-1" name="fnd-1"><sup>1</sup></a> are the basic argument type to all Octave functions - both for input and return arguments. In the example <pre class="example"> max (<var>a</var>, <var>b</var>) </pre> <p class="noindent">‘<samp><var>a</var><span class="samp">, </span><var>b</var></samp>’ is a comma separated list. Comma separated lists can appear on both the right and left hand side of an assignment. For example <pre class="example"> x = [1 0 1 0 0 1 1; 0 0 0 0 0 0 7]; [<var>i</var>, <var>j</var>] = find (<var>x</var>, 2, "last"); </pre> <p class="noindent">Here, ‘<samp><var>x</var><span class="samp">, 2, "last"</span></samp>’ is a comma separated list constituting the input arguments of <code>find</code>. <code>find</code> returns a comma separated list of output arguments which is assigned element by element to the comma separated list ‘<samp><var>i</var><span class="samp">, </span><var>j</var></samp>’. <p>Another example of where comma separated lists are used is in the creation of a new array with <code>[]</code> (see <a href="Matrices.html#Matrices">Matrices</a>) or the creation of a cell array with <code>{}</code> (see <a href="Basic-Usage-of-Cell-Arrays.html#Basic-Usage-of-Cell-Arrays">Basic Usage of Cell Arrays</a>). In the expressions <pre class="example"> a = [1, 2, 3, 4]; c = {4, 5, 6, 7}; </pre> <p class="noindent">both ‘<samp><span class="samp">1, 2, 3, 4</span></samp>’ and ‘<samp><span class="samp">4, 5, 6, 7</span></samp>’ are comma separated lists. <p>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. <ul class="menu"> <li><a accesskey="1" href="Comma-Separated-Lists-Generated-from-Cell-Arrays.html#Comma-Separated-Lists-Generated-from-Cell-Arrays">Comma Separated Lists Generated from Cell Arrays</a> <li><a accesskey="2" href="Comma-Separated-Lists-Generated-from-Structure-Arrays.html#Comma-Separated-Lists-Generated-from-Structure-Arrays">Comma Separated Lists Generated from Structure Arrays</a> </ul> <div class="footnote"> <hr> <h4>Footnotes</h4><p class="footnote"><small>[<a name="fn-1" href="#fnd-1">1</a>]</small> Comma-separated lists are also sometimes informally referred to as <dfn>cs-lists</dfn>.</p> <hr></div> </body></html>