File: Terminal-Output.html

package info (click to toggle)
octave 6.2.0-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 124,192 kB
  • sloc: cpp: 322,665; ansic: 68,088; fortran: 20,980; objc: 8,121; sh: 7,719; yacc: 4,266; lex: 4,123; perl: 1,530; java: 1,366; awk: 1,257; makefile: 424; xml: 147
file content (339 lines) | stat: -rw-r--r-- 14,155 bytes parent folder | download
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
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<!-- Created by GNU Texinfo 6.7, http://www.gnu.org/software/texinfo/ -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Terminal Output (GNU Octave (version 6.2.0))</title>

<meta name="description" content="Terminal Output (GNU Octave (version 6.2.0))">
<meta name="keywords" content="Terminal Output (GNU Octave (version 6.2.0))">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<meta name="Generator" content="makeinfo">
<link href="index.html" rel="start" title="Top">
<link href="Concept-Index.html" rel="index" title="Concept Index">
<link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
<link href="Basic-Input-and-Output.html" rel="up" title="Basic Input and Output">
<link href="Paging-Screen-Output.html" rel="next" title="Paging Screen Output">
<link href="Basic-Input-and-Output.html" rel="prev" title="Basic Input and Output">
<style type="text/css">
<!--
a.summary-letter {text-decoration: none}
blockquote.indentedblock {margin-right: 0em}
div.display {margin-left: 3.2em}
div.example {margin-left: 3.2em}
div.lisp {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}
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">
<span id="Terminal-Output"></span><div class="header">
<p>
Next: <a href="Terminal-Input.html" accesskey="n" rel="next">Terminal Input</a>, Up: <a href="Basic-Input-and-Output.html" accesskey="u" rel="up">Basic Input and Output</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Concept-Index.html" title="Index" rel="index">Index</a>]</p>
</div>
<hr>
<span id="Terminal-Output-1"></span><h4 class="subsection">14.1.1 Terminal Output</h4>

<p>Since Octave normally prints the value of an expression as soon as it
has been evaluated, the simplest of all I/O functions is a simple
expression.  For example, the following expression will display the
value of &lsquo;<samp>pi</samp>&rsquo;
</p>
<div class="example">
<pre class="example">pi
     -| ans =  3.1416
</pre></div>

<p>This works well as long as it is acceptable to have the name of the
variable (or &lsquo;<samp>ans</samp>&rsquo;) printed along with the value.  To print the
value of a variable without printing its name, use the function
<code>disp</code>.
</p>
<p>The <code>format</code> command offers some control over the way Octave prints
values with <code>disp</code> and through the normal echoing mechanism.
</p>
<span id="XREFdisp"></span><dl>
<dt id="index-disp">: <em></em> <strong>disp</strong> <em>(<var>x</var>)</em></dt>
<dt id="index-disp-1">: <em><var>str</var> =</em> <strong>disp</strong> <em>(<var>x</var>)</em></dt>
<dd><p>Display the value of <var>x</var>.
</p>
<p>For example:
</p>
<div class="example">
<pre class="example">disp (&quot;The value of pi is:&quot;), disp (pi)

     -| the value of pi is:
     -| 3.1416
</pre></div>

<p>Note that the output from <code>disp</code> always ends with a newline.
</p>
<p>If an output value is requested, <code>disp</code> prints nothing and returns the
formatted output in a string.
</p>
<p><strong>See also:</strong> <a href="Simple-File-I_002fO.html#XREFfdisp">fdisp</a>.
</p></dd></dl>


<span id="XREFlist_005fin_005fcolumns"></span><dl>
<dt id="index-list_005fin_005fcolumns">: <em></em> <strong>list_in_columns</strong> <em>(<var>arg</var>, <var>width</var>, <var>prefix</var>)</em></dt>
<dd><p>Return a string containing the elements of <var>arg</var> listed in columns with
an overall maximum width of <var>width</var> and optional prefix <var>prefix</var>.
</p>
<p>The argument <var>arg</var> must be a cell array of character strings or a
character array.
</p>
<p>If <var>width</var> is not specified or is an empty matrix, or less than or equal
to zero, the width of the terminal screen is used.  Newline characters are
used to break the lines in the output string.  For example:
</p>
<div class="example">
<pre class="example">list_in_columns ({&quot;abc&quot;, &quot;def&quot;, &quot;ghijkl&quot;, &quot;mnop&quot;, &quot;qrs&quot;, &quot;tuv&quot;}, 20)
     &rArr; abc     mnop
        def     qrs
        ghijkl  tuv

whos ans
     &rArr;
     Variables in the current scope:

       Attr Name        Size                     Bytes  Class
       ==== ====        ====                     =====  =====
            ans         1x37                        37  char

     Total is 37 elements using 37 bytes
</pre></div>


<p><strong>See also:</strong> <a href="#XREFterminal_005fsize">terminal_size</a>.
</p></dd></dl>


<span id="XREFterminal_005fsize"></span><dl>
<dt id="index-terminal_005fsize">: <em></em> <strong>terminal_size</strong> <em>()</em></dt>
<dd><p>Query or set the size of the terminal window.  If called with no
arguments, return a two-element row vector containing the current size
of the terminal window in characters (rows and columns).  If called with
a two-element vector of integer values, set the terminal size and return
the previous setting.  Setting the size manually should not be needed
when using readline for command-line editing.
</p>
<p><strong>See also:</strong> <a href="#XREFlist_005fin_005fcolumns">list_in_columns</a>.
</p></dd></dl>


<span id="XREFformat"></span><dl>
<dt id="index-format">: <em></em> <strong>format</strong></dt>
<dt id="index-format-1">: <em></em> <strong>format</strong> <em>options</em></dt>
<dt id="index-format-2">: <em>[<var>format</var>, <var>formatspacing</var>, <var>uppercase</var>] =</em> <strong>format</strong></dt>
<dd><p>Reset or specify the format of the output produced by <code>disp</code> and Octave&rsquo;s
normal echoing mechanism.
</p>
<p>This command only affects the display of numbers, but not how they are stored
or computed.  To change the internal representation from the default double use
one of the conversion functions such as <code>single</code>, <code>uint8</code>,
<code>int64</code>, etc.
</p>
<p>By default, Octave displays 5 significant digits in a human readable form
(option &lsquo;<samp>short</samp>&rsquo;, option &lsquo;<samp>lowercase</samp>&rsquo;, and option &lsquo;<samp>loose</samp>&rsquo; format
for matrices).  If <code>format</code> is invoked without any options, this default
format is restored.
</p>
<p>Valid format options for floating point numbers are listed in the following
table.
</p>
<dl compact="compact">
<dt><code>short</code></dt>
<dd><p>Fixed point format with 5 significant figures (default).
</p>
</dd>
<dt><code>long</code></dt>
<dd><p>Fixed point format with 16 significant figures.
</p>
<p>As with the &lsquo;<samp>short</samp>&rsquo; format, Octave will switch to an exponential &lsquo;<samp>e</samp>&rsquo;
format if it is unable to format a matrix properly using the current format.
</p>
</dd>
<dt><code>short e</code></dt>
<dt><code>long e</code></dt>
<dd><p>Exponential format.  The number to be represented is split between a mantissa
and an exponent (power of 10).  The mantissa has 5 significant digits in the
short format.  In the long format, double values are displayed with 16
significant digits and single values are displayed with 8.  For example,
with the &lsquo;<samp>short e</samp>&rsquo; format, <code>pi</code> is displayed as <code>3.1416e+00</code>.
</p>
</dd>
<dt><code>short g</code></dt>
<dt><code>long g</code></dt>
<dd><p>Optimally choose between fixed point and exponential format based on the
magnitude of the number.  For example, with the &lsquo;<samp>short g</samp>&rsquo; format,
<code>pi .^ [2; 4; 8; 16; 32]</code> is displayed as
</p>
<div class="example">
<pre class="example">ans =

      9.8696
      97.409
      9488.5
  9.0032e+07
  8.1058e+15
</pre></div>

</dd>
<dt><code>short eng</code></dt>
<dt><code>long eng</code></dt>
<dd><p>Identical to &lsquo;<samp>short e</samp>&rsquo; or &lsquo;<samp>long e</samp>&rsquo; but displays the value using an
engineering format, where the exponent is divisible by 3.  For example, with
the &lsquo;<samp>short eng</samp>&rsquo; format, <code>10 * pi</code> is displayed as <code>31.416e+00</code>.
</p>
</dd>
<dt><code>free</code></dt>
<dt><code>none</code></dt>
<dd><p>Print output in free format, without trying to line up columns of matrices on
the decimal point.  This is a raw format equivalent to the C++ code
<code>std::cout &lt;&lt; <var>variable</var></code>.  In general, the result is a presentation
with 6 significant digits where unnecessary precision (such as trailing zeros
for integers) is suppressed.  Complex numbers are formatted as numeric pairs
like this &lsquo;<samp>(0.60419, 0.60709)</samp>&rsquo; instead of like this
&lsquo;<samp>0.60419 + 0.60709i</samp>&rsquo;.
</p></dd>
</dl>

<p>The following formats affect all numeric output (floating point and integer
types).
</p>
<dl compact="compact">
<dt><code>&quot;+&quot;</code></dt>
<dt><code>&quot;+&quot;</code> <code>&quot;<var>chars</var>&quot;</code></dt>
<dt><code>plus</code></dt>
<dt><code>plus <var>chars</var></code></dt>
<dd><p>Print a &lsquo;<samp>+</samp>&rsquo; symbol for matrix elements greater than zero, a &lsquo;<samp>-</samp>&rsquo;
symbol for elements less than zero, and a space for zero matrix elements.  This
format can be useful for examining the sparsity structure of a large matrix.
For very large matrices the function <code>spy</code> which plots the sparsity
pattern will be clearer.
</p>
<p>The optional argument <var>chars</var> specifies a list of 3 characters to use for
printing values greater than zero, less than zero, and equal to zero.  For
example, with the format <code>&quot;+&quot; &quot;+-.&quot;</code>, the matrix
<code>[1, 0, -1; -1, 0, 1]</code> is displayed as
</p>
<div class="example">
<pre class="example">ans =

+.-
-.+
</pre></div>

</dd>
<dt>bank</dt>
<dd><p>Print variable in a format appropriate for a currency (fixed format with two
digits to the right of the decimal point).  Only the real part of a variable is
displayed, as the imaginary part makes no sense for a currency.
</p>
</dd>
<dt>native-hex</dt>
<dd><p>Print the hexadecimal representation of numbers as they are stored in memory.
For example, on a workstation which stores 8 byte real values in IEEE format
with the least significant byte first, the value of <code>pi</code> when printed in
<code>native-hex</code> format is <code>400921fb54442d18</code>.
</p>
</dd>
<dt>hex</dt>
<dd><p>The same as <code>native-hex</code>, but always print the most significant byte
first.
</p>
</dd>
<dt>native-bit</dt>
<dd><p>Print the bit representation of numbers as stored in memory.  For example, the
value of <code>pi</code> is
</p>
<div class="example">
<pre class="example">01000000000010010010000111111011
01010100010001000010110100011000
</pre></div>

<p>(shown here in two 32 bit sections for typesetting purposes) when printed in
native-bit format on a workstation which stores 8 byte real values in IEEE
format with the least significant byte first.
</p>
</dd>
<dt>bit</dt>
<dd><p>The same as <code>native-bit</code>, but always print the most significant bits
first.
</p>
</dd>
<dt>rat</dt>
<dd><p>Print a rational approximation, i.e., values are approximated as the ratio of
small integers.  For example, with the &lsquo;<samp>rat</samp>&rsquo; format, <code>pi</code> is
displayed as <code>355/113</code>.
</p></dd>
</dl>

<p>The following two options affect the display of scientific and hex notations.
</p>
<dl compact="compact">
<dt><code>lowercase (default)</code></dt>
<dd><p>Use a lowercase &lsquo;<samp>e</samp>&rsquo; for the exponent character in scientific notation and
lowercase &lsquo;<samp>a-f</samp>&rsquo; for the hex digits representing 10-15.
</p>
</dd>
<dt><code>uppercase</code></dt>
<dd><p>Use an uppercase &lsquo;<samp>E</samp>&rsquo; for the exponent character in scientific notation and
uppercase &lsquo;<samp>A-F</samp>&rsquo; for the hex digits representing 10-15.
</p></dd>
</dl>

<p>The following two options affect the display of all matrices.
</p>
<dl compact="compact">
<dt><code>compact</code></dt>
<dd><p>Remove blank lines around column number labels and between matrices producing
more compact output with more data per page.
</p>
</dd>
<dt><code>loose (default)</code></dt>
<dd><p>Insert blank lines above and below column number labels and between matrices to
produce a more readable output with less data per page.
</p></dd>
</dl>

<p>If <code>format</code> is called with multiple competing options, the rightmost one
is used.  In case of an error the format remains unchanged.
</p>
<p>If called with one to three output arguments, and no inputs, return the current
format, format spacing, and uppercase preference.
</p>

<p><strong>See also:</strong> <a href="Matrices.html#XREFfixed_005fpoint_005fformat">fixed_point_format</a>, <a href="Matrices.html#XREFoutput_005fprecision">output_precision</a>, <a href="Matrices.html#XREFsplit_005flong_005frows">split_long_rows</a>, <a href="Empty-Matrices.html#XREFprint_005fempty_005fdimensions">print_empty_dimensions</a>, <a href="Rational-Approximations.html#XREFrats">rats</a>.
</p></dd></dl>


<table class="menu" border="0" cellspacing="0">
<tr><td align="left" valign="top">&bull; <a href="Paging-Screen-Output.html" accesskey="1">Paging Screen Output</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
</td></tr>
</table>

<hr>
<div class="header">
<p>
Next: <a href="Terminal-Input.html" accesskey="n" rel="next">Terminal Input</a>, Up: <a href="Basic-Input-and-Output.html" accesskey="u" rel="up">Basic Input and Output</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Concept-Index.html" title="Index" rel="index">Index</a>]</p>
</div>



</body>
</html>