Sophie

Sophie

distrib > Mandriva > 2010.0 > i586 > media > contrib-release > by-pkgid > 3e60ff9d4d6f58c8fbd17208f14089fa > files > 100

octave-doc-3.2.3-3mdv2010.0.i586.rpm

<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:&nbsp;<a rel="previous" accesskey="p" href="Cell-Arrays.html#Cell-Arrays">Cell Arrays</a>,
Up:&nbsp;<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">&lsquo;<samp><var>a</var><span class="samp">, </span><var>b</var></samp>&rsquo; 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, &lsquo;<samp><var>x</var><span class="samp">, 2, "last"</span></samp>&rsquo; 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 &lsquo;<samp><var>i</var><span class="samp">, </span><var>j</var></samp>&rsquo;.

   <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 &lsquo;<samp><span class="samp">1, 2, 3, 4</span></samp>&rsquo; and &lsquo;<samp><span class="samp">4, 5, 6, 7</span></samp>&rsquo; 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>