/usr/share/doc/octave/octave.html/Creating-Cell-Arrays.html is in octave-doc 4.2.2-1ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 | <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<!-- Created by GNU Texinfo 6.5, http://www.gnu.org/software/texinfo/ -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Creating Cell Arrays (GNU Octave)</title>
<meta name="description" content="Creating Cell Arrays (GNU Octave)">
<meta name="keywords" content="Creating Cell Arrays (GNU Octave)">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<meta name="Generator" content="makeinfo">
<link href="index.html#Top" rel="start" title="Top">
<link href="Concept-Index.html#Concept-Index" rel="index" title="Concept Index">
<link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
<link href="Cell-Arrays.html#Cell-Arrays" rel="up" title="Cell Arrays">
<link href="Indexing-Cell-Arrays.html#Indexing-Cell-Arrays" rel="next" title="Indexing Cell Arrays">
<link href="Basic-Usage-of-Cell-Arrays.html#Basic-Usage-of-Cell-Arrays" rel="prev" title="Basic Usage of Cell Arrays">
<style type="text/css">
<!--
a.summary-letter {text-decoration: none}
blockquote.indentedblock {margin-right: 0em}
blockquote.smallindentedblock {margin-right: 0em; font-size: smaller}
blockquote.smallquotation {font-size: smaller}
div.display {margin-left: 3.2em}
div.example {margin-left: 3.2em}
div.lisp {margin-left: 3.2em}
div.smalldisplay {margin-left: 3.2em}
div.smallexample {margin-left: 3.2em}
div.smalllisp {margin-left: 3.2em}
kbd {font-style: oblique}
pre.display {font-family: inherit}
pre.format {font-family: inherit}
pre.menu-comment {font-family: serif}
pre.menu-preformatted {font-family: serif}
pre.smalldisplay {font-family: inherit; font-size: smaller}
pre.smallexample {font-size: smaller}
pre.smallformat {font-family: inherit; font-size: smaller}
pre.smalllisp {font-size: smaller}
span.nolinebreak {white-space: nowrap}
span.roman {font-family: initial; font-weight: normal}
span.sansserif {font-family: sans-serif; font-weight: normal}
ul.no-bullet {list-style: none}
-->
</style>
<link rel="stylesheet" type="text/css" href="octave.css">
</head>
<body lang="en">
<a name="Creating-Cell-Arrays"></a>
<div class="header">
<p>
Next: <a href="Indexing-Cell-Arrays.html#Indexing-Cell-Arrays" accesskey="n" rel="next">Indexing Cell Arrays</a>, Previous: <a href="Basic-Usage-of-Cell-Arrays.html#Basic-Usage-of-Cell-Arrays" accesskey="p" rel="prev">Basic Usage of Cell Arrays</a>, Up: <a href="Cell-Arrays.html#Cell-Arrays" accesskey="u" rel="up">Cell Arrays</a> [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Concept-Index.html#Concept-Index" title="Index" rel="index">Index</a>]</p>
</div>
<hr>
<a name="Creating-Cell-Arrays-1"></a>
<h4 class="subsection">6.2.2 Creating Cell Arrays</h4>
<p>The introductory example (see <a href="Basic-Usage-of-Cell-Arrays.html#Basic-Usage-of-Cell-Arrays">Basic Usage of Cell Arrays</a>) showed
how to create a cell array containing currently available variables.
In many situations, however, it is useful to create a cell array and
then fill it with data.
</p>
<p>The <code>cell</code> function returns a cell array of a given size, containing
empty matrices. This function is similar to the <code>zeros</code>
function for creating new numerical arrays. The following example creates
a 2-by-2 cell array containing empty matrices
</p>
<div class="example">
<pre class="example">c = cell (2,2)
⇒ c =
{
[1,1] = [](0x0)
[2,1] = [](0x0)
[1,2] = [](0x0)
[2,2] = [](0x0)
}
</pre></div>
<p>Just like numerical arrays, cell arrays can be multi-dimensional. The
<code>cell</code> function accepts any number of positive integers to describe
the size of the returned cell array. It is also possible to set the size
of the cell array through a vector of positive integers. In the
following example two cell arrays of equal size are created, and the size
of the first one is displayed
</p>
<div class="example">
<pre class="example">c1 = cell (3, 4, 5);
c2 = cell ( [3, 4, 5] );
size (c1)
⇒ ans =
3 4 5
</pre></div>
<p>As can be seen, the <a href="Object-Sizes.html#XREFsize">size</a> function also works
for cell arrays. As do other functions describing the size of an
object, such as <a href="Object-Sizes.html#XREFlength">length</a>, <a href="Object-Sizes.html#XREFnumel">numel</a>,
<a href="Object-Sizes.html#XREFrows">rows</a>, and <a href="Object-Sizes.html#XREFcolumns">columns</a>.
</p>
<a name="XREFcell"></a><dl>
<dt><a name="index-cell"></a>: <em></em> <strong>cell</strong> <em>(<var>n</var>)</em></dt>
<dt><a name="index-cell-1"></a>: <em></em> <strong>cell</strong> <em>(<var>m</var>, <var>n</var>)</em></dt>
<dt><a name="index-cell-2"></a>: <em></em> <strong>cell</strong> <em>(<var>m</var>, <var>n</var>, <var>k</var>, …)</em></dt>
<dt><a name="index-cell-3"></a>: <em></em> <strong>cell</strong> <em>([<var>m</var> <var>n</var> …])</em></dt>
<dd><p>Create a new cell array object.
</p>
<p>If invoked with a single scalar integer argument, return a square
NxN cell array. If invoked with two or more scalar integer
arguments, or a vector of integer values, return an array with the given
dimensions.
</p>
<p><strong>See also:</strong> <a href="Cell-Arrays-of-Strings.html#XREFcellstr">cellstr</a>, <a href="#XREFmat2cell">mat2cell</a>, <a href="#XREFnum2cell">num2cell</a>, <a href="Processing-Data-in-Structures.html#XREFstruct2cell">struct2cell</a>.
</p></dd></dl>
<p>As an alternative to creating empty cell arrays, and then filling them, it
is possible to convert numerical arrays into cell arrays using the
<code>num2cell</code>, <code>mat2cell</code> and <code>cellslices</code> functions.
</p>
<a name="XREFnum2cell"></a><dl>
<dt><a name="index-num2cell"></a>: <em><var>C</var> =</em> <strong>num2cell</strong> <em>(<var>A</var>)</em></dt>
<dt><a name="index-num2cell-1"></a>: <em><var>C</var> =</em> <strong>num2cell</strong> <em>(<var>A</var>, <var>dim</var>)</em></dt>
<dd><p>Convert the numeric matrix <var>A</var> to a cell array.
</p>
<p>If <var>dim</var> is defined, the value <var>C</var> is of dimension 1 in this
dimension and the elements of <var>A</var> are placed into <var>C</var> in slices.
For example:
</p>
<div class="example">
<pre class="example">num2cell ([1,2;3,4])
⇒
{
[1,1] = 1
[2,1] = 3
[1,2] = 2
[2,2] = 4
}
num2cell ([1,2;3,4],1)
⇒
{
[1,1] =
1
3
[1,2] =
2
4
}
</pre></div>
<p><strong>See also:</strong> <a href="#XREFmat2cell">mat2cell</a>.
</p></dd></dl>
<a name="XREFmat2cell"></a><dl>
<dt><a name="index-mat2cell"></a>: <em><var>C</var> =</em> <strong>mat2cell</strong> <em>(<var>A</var>, <var>m</var>, <var>n</var>)</em></dt>
<dt><a name="index-mat2cell-1"></a>: <em><var>C</var> =</em> <strong>mat2cell</strong> <em>(<var>A</var>, <var>d1</var>, <var>d2</var>, …)</em></dt>
<dt><a name="index-mat2cell-2"></a>: <em><var>C</var> =</em> <strong>mat2cell</strong> <em>(<var>A</var>, <var>r</var>)</em></dt>
<dd><p>Convert the matrix <var>A</var> to a cell array.
</p>
<p>If <var>A</var> is 2-D, then it is required that
<code>sum (<var>m</var>) == size (<var>A</var>, 1)</code> and
<code>sum (<var>n</var>) == size (<var>A</var>, 2)</code>. Similarly, if <var>A</var> is
multi-dimensional and the number of dimensional arguments is equal to the
dimensions of <var>A</var>, then it is required that
<code>sum (<var>di</var>) == size (<var>A</var>, i)</code>.
</p>
<p>Given a single dimensional argument <var>r</var>, the other dimensional
arguments are assumed to equal <code>size (<var>A</var>,<var>i</var>)</code>.
</p>
<p>An example of the use of mat2cell is
</p>
<div class="example">
<pre class="example">mat2cell (reshape (1:16,4,4), [3,1], [3,1])
⇒
{
[1,1] =
1 5 9
2 6 10
3 7 11
[2,1] =
4 8 12
[1,2] =
13
14
15
[2,2] = 16
}
</pre></div>
<p><strong>See also:</strong> <a href="#XREFnum2cell">num2cell</a>, <a href="Processing-Data-in-Cell-Arrays.html#XREFcell2mat">cell2mat</a>.
</p></dd></dl>
<a name="XREFcellslices"></a><dl>
<dt><a name="index-cellslices"></a>: <em><var>sl</var> =</em> <strong>cellslices</strong> <em>(<var>x</var>, <var>lb</var>, <var>ub</var>, <var>dim</var>)</em></dt>
<dd><p>Given an array <var>x</var>, this function produces a cell array of slices from
the array determined by the index vectors <var>lb</var>, <var>ub</var>, for lower and
upper bounds, respectively.
</p>
<p>In other words, it is equivalent to the following code:
</p>
<div class="example">
<pre class="example">n = length (lb);
sl = cell (1, n);
for i = 1:length (lb)
sl{i} = x(:,…,lb(i):ub(i),…,:);
endfor
</pre></div>
<p>The position of the index is determined by <var>dim</var>. If not specified,
slicing is done along the first non-singleton dimension.
</p>
<p><strong>See also:</strong> <a href="Processing-Data-in-Cell-Arrays.html#XREFcell2mat">cell2mat</a>, <a href="Indexing-Cell-Arrays.html#XREFcellindexmat">cellindexmat</a>, <a href="Function-Application.html#XREFcellfun">cellfun</a>.
</p></dd></dl>
<hr>
<div class="header">
<p>
Next: <a href="Indexing-Cell-Arrays.html#Indexing-Cell-Arrays" accesskey="n" rel="next">Indexing Cell Arrays</a>, Previous: <a href="Basic-Usage-of-Cell-Arrays.html#Basic-Usage-of-Cell-Arrays" accesskey="p" rel="prev">Basic Usage of Cell Arrays</a>, Up: <a href="Cell-Arrays.html#Cell-Arrays" accesskey="u" rel="up">Cell Arrays</a> [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Concept-Index.html#Concept-Index" title="Index" rel="index">Index</a>]</p>
</div>
</body>
</html>
|