File: Octave-FAQ_4.html

package info (click to toggle)
octave2.1 1%3A2.1.73-13
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 37,028 kB
  • ctags: 20,874
  • sloc: cpp: 106,508; fortran: 46,978; ansic: 5,720; sh: 4,800; makefile: 3,186; yacc: 3,132; lex: 2,892; lisp: 1,715; perl: 778; awk: 174; exp: 134
file content (578 lines) | stat: -rw-r--r-- 23,664 bytes parent folder | download | duplicates (3)
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
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
                      "http://www.w3.org/TR/html40/loose.dtd">
<HTML>
<!-- Created on January, 20 2004 by texi2html 1.66 -->
<!--
Written by: Lionel Cons <Lionel.Cons@cern.ch> (original author)
            Karl Berry  <karl@freefriends.org>
            Olaf Bachmann <obachman@mathematik.uni-kl.de>
            and many others.
Maintained by: Many creative people <dev@texi2html.cvshome.org>
Send bugs and suggestions to <users@texi2html.cvshome.org>

-->
<HEAD>
<TITLE>Frequently asked questions about Octave (with answers): Octave Features</TITLE>

<META NAME="description" CONTENT="Frequently asked questions about Octave (with answers): Octave Features">
<META NAME="keywords" CONTENT="Frequently asked questions about Octave (with answers): Octave Features">
<META NAME="resource-type" CONTENT="document">
<META NAME="distribution" CONTENT="global">
<META NAME="Generator" CONTENT="texi2html 1.66">

</HEAD>

<BODY LANG="en" BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#800080" ALINK="#FF0000">

<A NAME="SEC4"></A>
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="Octave-FAQ_3.html#SEC3"> &lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="Octave-FAQ_4.html#SEC5"> &gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="Octave-FAQ_3.html#SEC3"> &lt;&lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="Octave-FAQ.html#SEC_Top"> Up </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="Octave-FAQ_5.html#SEC14"> &gt;&gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="Octave-FAQ.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="Octave-FAQ_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[Index]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="Octave-FAQ_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<H1> 3. What features are unique to Octave? </H1>
<!--docid::SEC4::-->
<P>

<TABLE BORDER="0" CELLSPACING="0">
<TR><TD ALIGN="left" VALIGN="TOP"><A HREF="Octave-FAQ_4.html#SEC5">3.1 Command and variable name completion</A></TD><TD>&nbsp;&nbsp;</TD><TD ALIGN="left" VALIGN="TOP"></TD></TR>
<TR><TD ALIGN="left" VALIGN="TOP"><A HREF="Octave-FAQ_4.html#SEC6">3.2 Command history</A></TD><TD>&nbsp;&nbsp;</TD><TD ALIGN="left" VALIGN="TOP"></TD></TR>
<TR><TD ALIGN="left" VALIGN="TOP"><A HREF="Octave-FAQ_4.html#SEC7">3.3 Data structures</A></TD><TD>&nbsp;&nbsp;</TD><TD ALIGN="left" VALIGN="TOP"></TD></TR>
<TR><TD ALIGN="left" VALIGN="TOP"><A HREF="Octave-FAQ_4.html#SEC8">3.4 Short-circuit boolean operators</A></TD><TD>&nbsp;&nbsp;</TD><TD ALIGN="left" VALIGN="TOP"></TD></TR>
<TR><TD ALIGN="left" VALIGN="TOP"><A HREF="Octave-FAQ_4.html#SEC9">3.5 Increment and decrement operators</A></TD><TD>&nbsp;&nbsp;</TD><TD ALIGN="left" VALIGN="TOP"></TD></TR>
<TR><TD ALIGN="left" VALIGN="TOP"><A HREF="Octave-FAQ_4.html#SEC10">3.6 Unwind-protect</A></TD><TD>&nbsp;&nbsp;</TD><TD ALIGN="left" VALIGN="TOP"></TD></TR>
<TR><TD ALIGN="left" VALIGN="TOP"><A HREF="Octave-FAQ_4.html#SEC11">3.7 Variable-length argument lists</A></TD><TD>&nbsp;&nbsp;</TD><TD ALIGN="left" VALIGN="TOP"></TD></TR>
<TR><TD ALIGN="left" VALIGN="TOP"><A HREF="Octave-FAQ_4.html#SEC12">3.8 Variable-length return lists</A></TD><TD>&nbsp;&nbsp;</TD><TD ALIGN="left" VALIGN="TOP"></TD></TR>
<TR><TD ALIGN="left" VALIGN="TOP"><A HREF="Octave-FAQ_4.html#SEC13">3.9 Built-in ODE and DAE solvers</A></TD><TD>&nbsp;&nbsp;</TD><TD ALIGN="left" VALIGN="TOP"></TD></TR>
</TABLE>
<P>

<A NAME="Command and variable name completion"></A>
<HR SIZE="6">
<A NAME="SEC5"></A>
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="Octave-FAQ_4.html#SEC4"> &lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="Octave-FAQ_4.html#SEC6"> &gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="Octave-FAQ_4.html#SEC4"> &lt;&lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="Octave-FAQ_4.html#SEC4"> Up </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="Octave-FAQ_5.html#SEC14"> &gt;&gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="Octave-FAQ.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="Octave-FAQ_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[Index]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="Octave-FAQ_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<H2> 3.1 Command and variable name completion </H2>
<!--docid::SEC5::-->
<P>

<A NAME="IDX1"></A>
<A NAME="IDX2"></A>
<A NAME="IDX3"></A>
<A NAME="IDX4"></A>
</P>
<P>

Typing a TAB character (ASCII code 9) on the command line causes Octave
to attempt to complete variable, function, and file names.  Octave uses
the text before the cursor as the initial portion of the name to
complete.
</P>
<P>

For example, if you type `<SAMP>fu</SAMP>' followed by TAB at the Octave prompt,
Octave will complete the rest of the name `<SAMP>function</SAMP>' on the command
line (unless you have other variables or functions defined that begin
with the characters `<SAMP>fu</SAMP>').  If there is more than one possible
completion, Octave will ring the terminal bell to let you know that your
initial sequence of characters is not enough to specify a unique name.
To complete the name, you may either edit the initial character sequence
(usually adding more characters until completion is possible) or type
another TAB to cause Octave to display the list of possible completions.
</P>
<P>

<A NAME="Command history"></A>
<HR SIZE="6">
<A NAME="SEC6"></A>
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="Octave-FAQ_4.html#SEC5"> &lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="Octave-FAQ_4.html#SEC7"> &gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="Octave-FAQ_4.html#SEC4"> &lt;&lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="Octave-FAQ_4.html#SEC4"> Up </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="Octave-FAQ_5.html#SEC14"> &gt;&gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="Octave-FAQ.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="Octave-FAQ_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[Index]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="Octave-FAQ_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<H2> 3.2 Command history </H2>
<!--docid::SEC6::-->
<P>

<A NAME="IDX5"></A>
<A NAME="IDX6"></A>
</P>
<P>

When running interactively, Octave saves the commands you type in an
internal buffer so that you can recall and edit them.  Emacs and vi
editing modes are available with Emacs keybindings enabled by default.
</P>
<P>

When Octave exits, the current command history is saved to the file
`<TT>~/.octave_hist</TT>', and each time Octave starts, it inserts the
contents of the `<TT>~/.octave_hist</TT>' file in the history list so that
it is easy to begin working where you left off.
</P>
<P>

<A NAME="Data structures"></A>
<HR SIZE="6">
<A NAME="SEC7"></A>
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="Octave-FAQ_4.html#SEC6"> &lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="Octave-FAQ_4.html#SEC8"> &gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="Octave-FAQ_4.html#SEC4"> &lt;&lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="Octave-FAQ_4.html#SEC4"> Up </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="Octave-FAQ_5.html#SEC14"> &gt;&gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="Octave-FAQ.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="Octave-FAQ_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[Index]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="Octave-FAQ_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<H2> 3.3 Data structures </H2>
<!--docid::SEC7::-->
<P>

<A NAME="IDX7"></A>
<A NAME="IDX8"></A>
</P>
<P>

Octave includes a limited amount of support for organizing data in
structures.  The current implementation uses an associative array
with indices limited to strings, but the syntax is more like C-style
structures.  Here are some examples of using data structures in Octave.
</P>
<P>

<UL>
<LI>Elements of structures can be of any value type.
<P>

<TABLE><tr><td>&nbsp;</td><td class=example><pre>octave:1&gt; x.a = 1; x.b = [1, 2; 3, 4]; x.c = &quot;string&quot;;
octave:2&gt; x.a
x.a = 1
octave:3&gt; x.b
x.b =

  1  2
  3  4

octave:4&gt; x.c
x.c = string
</pre></td></tr></table><P>

</P>
<LI>Structures may be copied.
<P>

<TABLE><tr><td>&nbsp;</td><td class=example><pre>octave:1&gt; y = x
y =
{
  a = 1
  b =

    1  2
    3  4

  c = string
  s =

    0.00000  0.00000  0.00000
    0.00000  5.46499  0.00000
    0.00000  0.00000  0.36597

  u =

    -0.40455  -0.91451
    -0.91451   0.40455

  v =

    -0.57605   0.81742
    -0.81742  -0.57605
}
</pre></td></tr></table><P>

</P>
<LI>Structure elements may reference other structures.
<P>

<TABLE><tr><td>&nbsp;</td><td class=example><pre>octave:1&gt; x.b.d = 3
x.b.d = 3
octave:2&gt; x.b
ans =
{
  d = 3
}
octave:3&gt; x.b.d
ans = 3
</pre></td></tr></table><P>

</P>
<LI>Functions can return structures.
<P>

<TABLE><tr><td>&nbsp;</td><td class=example><pre>octave:1&gt; function y = f (x)
&gt; y.re = real (x);
&gt; y.im = imag (x);
&gt; endfunction

octave:2&gt; f (rand + rand*I);
ans =
{
  im = 0.18033
  re = 0.19069
}
</pre></td></tr></table><P>

</P>
<LI>Function return lists can include structure elements, and they may
be indexed like any other variable.
<P>

<TABLE><tr><td>&nbsp;</td><td class=example><pre>octave:1&gt; [x.u, x.s(2:3,2:3), x.v] = svd ([1, 2; 3, 4]);
octave:2&gt; x
x =
{
  s =

    0.00000  0.00000  0.00000
    0.00000  5.46499  0.00000
    0.00000  0.00000  0.36597

  u =

    -0.40455  -0.91451
    -0.91451   0.40455

  v =

    -0.57605   0.81742
    -0.81742  -0.57605
}
</pre></td></tr></table><P>

</P>
<LI>You can also use the function <CODE>is_struct</CODE> to determine
whether a given value is a data structure.  For example
<P>

<TABLE><tr><td>&nbsp;</td><td class=example><pre>is_struct (x)
</pre></td></tr></table><P>

returns 1 if the value of the variable <VAR>x</VAR> is a data structure.
</UL>
<P>

This feature should be considered experimental, but you should expect it
to work.  Suggestions for ways to improve it are welcome.
</P>
<P>

<A NAME="Short-circuit boolean operators"></A>
<HR SIZE="6">
<A NAME="SEC8"></A>
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="Octave-FAQ_4.html#SEC7"> &lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="Octave-FAQ_4.html#SEC9"> &gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="Octave-FAQ_4.html#SEC4"> &lt;&lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="Octave-FAQ_4.html#SEC4"> Up </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="Octave-FAQ_5.html#SEC14"> &gt;&gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="Octave-FAQ.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="Octave-FAQ_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[Index]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="Octave-FAQ_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<H2> 3.4 Short-circuit boolean operators </H2>
<!--docid::SEC8::-->
<P>

<A NAME="IDX9"></A>
<A NAME="IDX10"></A>
<A NAME="IDX11"></A>
<A NAME="IDX12"></A>
</P>
<P>

Octave's `<SAMP>&amp;&amp;</SAMP>' and `<SAMP>||</SAMP>' logical operators are evaluated in
a short-circuit fashion (like the corresponding operators in the C
language) and work differently than the element by element operators
`<SAMP>&amp;</SAMP>' and `<SAMP>|</SAMP>'.
</P>
<P>

<A NAME="Increment and decrement operators"></A>
<HR SIZE="6">
<A NAME="SEC9"></A>
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="Octave-FAQ_4.html#SEC8"> &lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="Octave-FAQ_4.html#SEC10"> &gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="Octave-FAQ_4.html#SEC4"> &lt;&lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="Octave-FAQ_4.html#SEC4"> Up </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="Octave-FAQ_5.html#SEC14"> &gt;&gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="Octave-FAQ.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="Octave-FAQ_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[Index]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="Octave-FAQ_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<H2> 3.5 Increment and decrement operators </H2>
<!--docid::SEC9::-->
<P>

<A NAME="IDX13"></A>
<A NAME="IDX14"></A>
<A NAME="IDX15"></A>
<A NAME="IDX16"></A>
</P>
<P>

Octave includes the C-like increment and decrement operators `<SAMP>++</SAMP>'
and `<SAMP>--</SAMP>' in both their prefix and postfix forms.
</P>
<P>

For example, to pre-increment the variable <VAR>x</VAR>, you would write
<CODE>++<VAR>x</VAR></CODE>.  This would add one to <VAR>x</VAR> and then return the new
value of <VAR>x</VAR> as the result of the expression.  It is exactly the
same as the expression <CODE><VAR>x</VAR> = <VAR>x</VAR> + 1</CODE>.
</P>
<P>

To post-increment a variable <VAR>x</VAR>, you would write <CODE><VAR>x</VAR>++</CODE>.
This adds one to the variable <VAR>x</VAR>, but returns the value that
<VAR>x</VAR> had prior to incrementing it.  For example, if <VAR>x</VAR> is equal
to 2, the result of the expression <CODE><VAR>x</VAR>++</CODE> is 2, and the new
value of <VAR>x</VAR> is 3.
</P>
<P>

For matrix and vector arguments, the increment and decrement operators
work on each element of the operand.
</P>
<P>

It is not currently possible to increment index expressions.  For
example, you might expect that the expression <CODE><VAR>v</VAR>(4)++</CODE> would
increment the fourth element of the vector <VAR>v</VAR>, but instead it
results in a parse error.  This problem may be fixed in a future
release of Octave.
</P>
<P>

<A NAME="Unwind-protect"></A>
<HR SIZE="6">
<A NAME="SEC10"></A>
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="Octave-FAQ_4.html#SEC9"> &lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="Octave-FAQ_4.html#SEC11"> &gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="Octave-FAQ_4.html#SEC4"> &lt;&lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="Octave-FAQ_4.html#SEC4"> Up </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="Octave-FAQ_5.html#SEC14"> &gt;&gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="Octave-FAQ.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="Octave-FAQ_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[Index]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="Octave-FAQ_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<H2> 3.6 Unwind-protect </H2>
<!--docid::SEC10::-->
<P>

<A NAME="IDX17"></A>
</P>
<P>

Octave supports a limited form of exception handling modelled after the
unwind-protect form of Lisp.  The general form of an
<CODE>unwind_protect</CODE> block looks like this:
</P>
<P>

<TABLE><tr><td>&nbsp;</td><td class=example><pre>unwind_protect
  <VAR>body</VAR>
unwind_protect_cleanup
  <VAR>cleanup</VAR>
end_unwind_protect
</pre></td></tr></table><P>

Where <VAR>body</VAR> and <VAR>cleanup</VAR> are both optional and may contain any
Octave expressions or commands.  The statements in <VAR>cleanup</VAR> are 
guaranteed to be executed regardless of how control exits <VAR>body</VAR>.
</P>
<P>

The <CODE>unwind_protect</CODE> statement is often used to reliably restore
the values of global variables that need to be temporarily changed.
</P>
<P>

<A NAME="Variable-length argument lists"></A>
<HR SIZE="6">
<A NAME="SEC11"></A>
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="Octave-FAQ_4.html#SEC10"> &lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="Octave-FAQ_4.html#SEC12"> &gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="Octave-FAQ_4.html#SEC4"> &lt;&lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="Octave-FAQ_4.html#SEC4"> Up </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="Octave-FAQ_5.html#SEC14"> &gt;&gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="Octave-FAQ.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="Octave-FAQ_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[Index]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="Octave-FAQ_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<H2> 3.7 Variable-length argument lists </H2>
<!--docid::SEC11::-->
<P>

<A NAME="IDX18"></A>
<A NAME="IDX19"></A>
</P>
<P>

Octave has a real mechanism for handling functions that take an
unspecified number of arguments, so it is no longer necessary to place
an upper bound on the number of optional arguments that a function can
accept.
</P>
<P>

Here is an example of a function that uses the new syntax to print a
header followed by an unspecified number of values:
</P>
<P>

<TABLE><tr><td>&nbsp;</td><td class=example><pre>function foo (heading, ...)
  disp (heading);
  va_start ();
  while (--nargin)
    disp (va_arg ());
  endwhile
endfunction
</pre></td></tr></table><P>

Calling <CODE>va_start()</CODE> positions an internal pointer to the first
unnamed argument and allows you to cycle through the arguments more than
once.  It is not necessary to call <CODE>va_start()</CODE> if you do not plan
to cycle through the arguments more than once.
</P>
<P>

The function <CODE>va_arg()</CODE> returns the value of the next available
argument and moves the internal pointer to the next argument.  It is an
error to call <CODE>va_arg()</CODE> when there are no more arguments
available.
</P>
<P>

It is also possible to use the keyword <VAR>all_va_args</VAR> to pass all
unnamed arguments to another function.
</P>
<P>

<A NAME="Variable-length return lists"></A>
<HR SIZE="6">
<A NAME="SEC12"></A>
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="Octave-FAQ_4.html#SEC11"> &lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="Octave-FAQ_4.html#SEC13"> &gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="Octave-FAQ_4.html#SEC4"> &lt;&lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="Octave-FAQ_4.html#SEC4"> Up </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="Octave-FAQ_5.html#SEC14"> &gt;&gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="Octave-FAQ.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="Octave-FAQ_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[Index]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="Octave-FAQ_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<H2> 3.8 Variable-length return lists </H2>
<!--docid::SEC12::-->
<P>

<A NAME="IDX20"></A>
<A NAME="IDX21"></A>
</P>
<P>

Octave also has a real mechanism for handling functions that return an
unspecified number of values, so it is no longer necessary to place an
upper bound on the number of outputs that a function can produce.
</P>
<P>

Here is an example of a function that uses the new syntax to produce
`<SAMP>N</SAMP>' values:
</P>
<P>

<TABLE><tr><td>&nbsp;</td><td class=example><pre>function [...] = foo (n)
  for i = 1:n
    vr_val (i);
  endfor
endfunction
</pre></td></tr></table><P>

<A NAME="Built-in ODE and DAE solvers"></A>
<HR SIZE="6">
<A NAME="SEC13"></A>
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="Octave-FAQ_4.html#SEC12"> &lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="Octave-FAQ_5.html#SEC14"> &gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="Octave-FAQ_4.html#SEC4"> &lt;&lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="Octave-FAQ_4.html#SEC4"> Up </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="Octave-FAQ_5.html#SEC14"> &gt;&gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="Octave-FAQ.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="Octave-FAQ_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[Index]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="Octave-FAQ_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<H2> 3.9 Built-in ODE and DAE solvers </H2>
<!--docid::SEC13::-->
<P>

<A NAME="IDX22"></A>
<A NAME="IDX23"></A>
</P>
<P>

Octave includes LSODE and DASSL for solving systems of stiff ordinary
differential and differential-algebraic equations.  These functions are
built in to the interpreter.
</P>
<P>

<A NAME="Documentation"></A>
<HR SIZE="6">
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="Octave-FAQ_4.html#SEC4"> &lt;&lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="Octave-FAQ_5.html#SEC14"> &gt;&gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="Octave-FAQ.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="Octave-FAQ_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[Index]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="Octave-FAQ_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<BR>
<FONT SIZE="-1">
This document was generated
by <I>John W. Eaton</I> on <I>January, 20 2004</I>
using <A HREF="http://texi2html.cvshome.org"><I>texi2html</I></A>
</FONT>

</BODY>
</HTML>