annotate doc/interpreter/intro.texi @ 3180:c17387059fd3

[project @ 1998-09-24 18:59:11 by jwe]
author jwe
date Thu, 24 Sep 1998 19:00:19 +0000
parents 91589ab98e37
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2670
18192eea4973 [project @ 1997-02-13 18:29:53 by jwe]
jwe
parents: 2653
diff changeset
1 @c Copyright (C) 1996, 1997 John W. Eaton
2333
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
2 @c This is part of the Octave manual.
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
3 @c For copying conditions, see the file gpl.texi.
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
4
2670
18192eea4973 [project @ 1997-02-13 18:29:53 by jwe]
jwe
parents: 2653
diff changeset
5 @node Introduction, Getting Started, Preface, Top
2333
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
6 @chapter A Brief Introduction to Octave
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
7 @cindex introduction
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
8
2993
91589ab98e37 [project @ 1997-05-21 21:44:54 by jwe]
jwe
parents: 2759
diff changeset
9 This manual documents how to run, install and port GNU Octave, and how
91589ab98e37 [project @ 1997-05-21 21:44:54 by jwe]
jwe
parents: 2759
diff changeset
10 to report bugs.
2333
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
11
2993
91589ab98e37 [project @ 1997-05-21 21:44:54 by jwe]
jwe
parents: 2759
diff changeset
12 GNU Octave is a high-level language, primarily intended for numerical
2333
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
13 computations. It provides a convenient command line interface for
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
14 solving linear and nonlinear problems numerically, and for performing
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
15 other numerical experiments. It may also be used as a batch-oriented
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
16 language.
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
17
2993
91589ab98e37 [project @ 1997-05-21 21:44:54 by jwe]
jwe
parents: 2759
diff changeset
18 GNU Octave is also freely redistributable software. You may
91589ab98e37 [project @ 1997-05-21 21:44:54 by jwe]
jwe
parents: 2759
diff changeset
19 redistribute it and/or modify it under the terms of the GNU General
91589ab98e37 [project @ 1997-05-21 21:44:54 by jwe]
jwe
parents: 2759
diff changeset
20 Public License as published by the Free Software Foundation. The GPL is
91589ab98e37 [project @ 1997-05-21 21:44:54 by jwe]
jwe
parents: 2759
diff changeset
21 included in this manual in @ref{Copying}.
2449
31d5588dbb61 [project @ 1996-10-30 22:58:44 by jwe]
jwe
parents: 2333
diff changeset
22
2333
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
23 This document corresponds to Octave version @value{VERSION}.
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
24
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
25 @c XXX FIXME XXX -- add explanation about how and why Octave was written.
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
26 @c
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
27 @c XXX FIXME XXX -- add a sentence or two explaining that we could
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
28 @c always use more funding.
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
29
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
30 @menu
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
31 * Running Octave::
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
32 * Simple Examples::
2653
e7908588548a [project @ 1997-02-01 16:53:52 by jwe]
jwe
parents: 2449
diff changeset
33 * Conventions::
2333
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
34 @end menu
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
35
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
36 @node Running Octave, Simple Examples, Introduction, Introduction
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
37 @section Running Octave
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
38
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
39 On most systems, the way to invoke Octave is with the shell command
2993
91589ab98e37 [project @ 1997-05-21 21:44:54 by jwe]
jwe
parents: 2759
diff changeset
40 @samp{octave}. Octave displays an initial message and then a prompt
2333
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
41 indicating it is ready to accept input. You can begin typing Octave
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
42 commands immediately afterward.
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
43
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
44 If you get into trouble, you can usually interrupt Octave by typing
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
45 @kbd{Control-C} (usually written @kbd{C-c} for short). @kbd{C-c} gets
2670
18192eea4973 [project @ 1997-02-13 18:29:53 by jwe]
jwe
parents: 2653
diff changeset
46 its name from the fact that you type it by holding down @key{CTRL} and
18192eea4973 [project @ 1997-02-13 18:29:53 by jwe]
jwe
parents: 2653
diff changeset
47 then pressing @key{c}. Doing this will normally return you to Octave's
18192eea4973 [project @ 1997-02-13 18:29:53 by jwe]
jwe
parents: 2653
diff changeset
48 prompt.
2333
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
49
2449
31d5588dbb61 [project @ 1996-10-30 22:58:44 by jwe]
jwe
parents: 2333
diff changeset
50 @cindex exiting octave
31d5588dbb61 [project @ 1996-10-30 22:58:44 by jwe]
jwe
parents: 2333
diff changeset
51 @cindex quitting octave
2689
8c7955a8d49f [project @ 1997-02-18 09:06:10 by jwe]
jwe
parents: 2670
diff changeset
52 To exit Octave, type @kbd{quit}, or @kbd{exit} at the Octave prompt.
2333
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
53
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
54 On systems that support job control, you can suspend Octave by sending
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
55 it a @code{SIGTSTP} signal, usually by typing @kbd{C-z}.
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
56
2653
e7908588548a [project @ 1997-02-01 16:53:52 by jwe]
jwe
parents: 2449
diff changeset
57 @node Simple Examples, Conventions, Running Octave, Introduction
2333
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
58 @section Simple Examples
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
59
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
60 The following chapters describe all of Octave's features in detail, but
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
61 before doing that, it might be helpful to give a sampling of some of its
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
62 capabilities.
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
63
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
64 If you are new to Octave, I recommend that you try these examples to
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
65 begin learning Octave by using it. Lines marked with @samp{octave:13>}
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
66 are lines you type, ending each with a carriage return. Octave will
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
67 respond with an answer, or by displaying a graph.
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
68
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
69 @unnumberedsubsec Creating a Matrix
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
70
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
71 To create a new matrix and store it in a variable so that it you can
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
72 refer to it later, type the command
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
73
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
74 @example
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
75 octave:1> a = [ 1, 1, 2; 3, 5, 8; 13, 21, 34 ]
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
76 @end example
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
77
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
78 @noindent
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
79 Octave will respond by printing the matrix in neatly aligned columns.
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
80 Ending a command with a semicolon tells Octave to not print the result
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
81 of a command. For example
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
82
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
83 @example
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
84 octave:2> b = rand (3, 2);
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
85 @end example
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
86
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
87 @noindent
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
88 will create a 3 row, 2 column matrix with each element set to a random
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
89 value between zero and one.
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
90
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
91 To display the value of any variable, simply type the name of the
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
92 variable. For example, to display the value stored in the matrix
2689
8c7955a8d49f [project @ 1997-02-18 09:06:10 by jwe]
jwe
parents: 2670
diff changeset
93 @code{b}, type the command
2333
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
94
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
95 @example
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
96 octave:3> b
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
97 @end example
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
98
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
99 @unnumberedsubsec Matrix Arithmetic
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
100
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
101 Octave has a convenient operator notation for performing matrix
2689
8c7955a8d49f [project @ 1997-02-18 09:06:10 by jwe]
jwe
parents: 2670
diff changeset
102 arithmetic. For example, to multiply the matrix @code{a} by a scalar
2333
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
103 value, type the command
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
104
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
105 @example
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
106 octave:4> 2 * a
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
107 @end example
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
108
2689
8c7955a8d49f [project @ 1997-02-18 09:06:10 by jwe]
jwe
parents: 2670
diff changeset
109 To multiply the two matrices @code{a} and @code{b}, type the command
2333
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
110
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
111 @example
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
112 octave:5> a * b
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
113 @end example
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
114
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
115 To form the matrix product
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
116 @iftex
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
117 @tex
2689
8c7955a8d49f [project @ 1997-02-18 09:06:10 by jwe]
jwe
parents: 2670
diff changeset
118 $@code{a}^T@code{a}$,
2333
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
119 @end tex
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
120 @end iftex
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
121 @ifinfo
2689
8c7955a8d49f [project @ 1997-02-18 09:06:10 by jwe]
jwe
parents: 2670
diff changeset
122 @code{transpose (a) * a},
2333
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
123 @end ifinfo
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
124 type the command
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
125
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
126 @example
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
127 octave:6> a' * a
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
128 @end example
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
129
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
130 @unnumberedsubsec Solving Linear Equations
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
131
2689
8c7955a8d49f [project @ 1997-02-18 09:06:10 by jwe]
jwe
parents: 2670
diff changeset
132 To solve the set of linear equations @code{a@var{x} = b},
2333
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
133 use the left division operator, @samp{\}:
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
134
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
135 @example
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
136 octave:7> a \ b
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
137 @end example
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
138
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
139 @noindent
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
140 This is conceptually equivalent to
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
141 @iftex
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
142 @tex
2689
8c7955a8d49f [project @ 1997-02-18 09:06:10 by jwe]
jwe
parents: 2670
diff changeset
143 $@code{a}^{-1}@code{b}$,
2333
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
144 @end tex
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
145 @end iftex
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
146 @ifinfo
2689
8c7955a8d49f [project @ 1997-02-18 09:06:10 by jwe]
jwe
parents: 2670
diff changeset
147 @code{inv (a) * b},
2333
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
148 @end ifinfo
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
149 but avoids computing the inverse of a matrix directly.
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
150
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
151 If the coefficient matrix is singular, Octave will print a warning
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
152 message and compute a minimum norm solution.
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
153
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
154 @unnumberedsubsec Integrating Differential Equations
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
155
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
156 Octave has built-in functions for solving nonlinear differential
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
157 equations of the form
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
158 @iftex
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
159 @tex
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
160 $$
2689
8c7955a8d49f [project @ 1997-02-18 09:06:10 by jwe]
jwe
parents: 2670
diff changeset
161 {dx \over dt} = f(x,t), \qquad x(t=t_0) = x_0
2333
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
162 $$
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
163 @end tex
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
164 @end iftex
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
165 @ifinfo
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
166
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
167 @example
2449
31d5588dbb61 [project @ 1996-10-30 22:58:44 by jwe]
jwe
parents: 2333
diff changeset
168 @group
2333
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
169 dx
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
170 -- = f (x, t)
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
171 dt
2449
31d5588dbb61 [project @ 1996-10-30 22:58:44 by jwe]
jwe
parents: 2333
diff changeset
172 @end group
2333
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
173 @end example
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
174
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
175 @noindent
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
176 with the initial condition
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
177
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
178 @example
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
179 x(t = t0) = x0
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
180 @end example
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
181 @end ifinfo
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
182
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
183 @noindent
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
184 For Octave to integrate equations of this form, you must first provide a
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
185 definition of the function
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
186 @iftex
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
187 @tex
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
188 $f (x, t)$.
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
189 @end tex
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
190 @end iftex
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
191 @ifinfo
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
192 @code{f(x,t)}.
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
193 @end ifinfo
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
194 This is straightforward, and may be accomplished by entering the
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
195 function body directly on the command line. For example, the following
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
196 commands define the right hand side function for an interesting pair of
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
197 nonlinear differential equations. Note that while you are entering a
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
198 function, Octave responds with a different prompt, to indicate that it
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
199 is waiting for you to complete your input.
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
200
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
201 @example
2449
31d5588dbb61 [project @ 1996-10-30 22:58:44 by jwe]
jwe
parents: 2333
diff changeset
202 @group
2333
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
203 octave:8> function xdot = f (x, t)
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
204 >
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
205 > r = 0.25;
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
206 > k = 1.4;
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
207 > a = 1.5;
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
208 > b = 0.16;
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
209 > c = 0.9;
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
210 > d = 0.8;
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
211 >
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
212 > xdot(1) = r*x(1)*(1 - x(1)/k) - a*x(1)*x(2)/(1 + b*x(1));
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
213 > xdot(2) = c*a*x(1)*x(2)/(1 + b*x(1)) - d*x(2);
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
214 >
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
215 > endfunction
2449
31d5588dbb61 [project @ 1996-10-30 22:58:44 by jwe]
jwe
parents: 2333
diff changeset
216 @end group
2333
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
217 @end example
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
218
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
219 @noindent
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
220 Given the initial condition
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
221
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
222 @example
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
223 x0 = [1; 2];
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
224 @end example
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
225
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
226 @noindent
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
227 and the set of output times as a column vector (note that the first
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
228 output time corresponds to the initial condition given above)
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
229
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
230 @example
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
231 t = linspace (0, 50, 200)';
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
232 @end example
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
233
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
234 @noindent
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
235 it is easy to integrate the set of differential equations:
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
236
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
237 @example
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
238 x = lsode ("f", x0, t);
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
239 @end example
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
240
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
241 @noindent
2689
8c7955a8d49f [project @ 1997-02-18 09:06:10 by jwe]
jwe
parents: 2670
diff changeset
242 The function @code{lsode} uses the Livermore Solver for Ordinary
2333
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
243 Differential Equations, described in A. C. Hindmarsh, @cite{ODEPACK, a
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
244 Systematized Collection of ODE Solvers}, in: Scientific Computing, R. S.
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
245 Stepleman et al. (Eds.), North-Holland, Amsterdam, 1983, pages 55--64.
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
246
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
247 @unnumberedsubsec Producing Graphical Output
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
248
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
249 To display the solution of the previous example graphically, use the
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
250 command
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
251
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
252 @example
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
253 plot (t, x)
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
254 @end example
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
255
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
256 If you are using the X Window System, Octave will automatically create
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
257 a separate window to display the plot. If you are using a terminal that
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
258 supports some other graphics commands, you will need to tell Octave what
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
259 kind of terminal you have. Type the command
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
260
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
261 @example
2689
8c7955a8d49f [project @ 1997-02-18 09:06:10 by jwe]
jwe
parents: 2670
diff changeset
262 gset term
2333
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
263 @end example
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
264
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
265 @noindent
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
266 to see a list of the supported terminal types. Octave uses
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
267 @code{gnuplot} to display graphics, and can display graphics on any
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
268 terminal that is supported by @code{gnuplot}.
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
269
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
270 To capture the output of the plot command in a file rather than sending
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
271 the output directly to your terminal, you can use a set of commands like
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
272 this
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
273
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
274 @example
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
275 @group
2689
8c7955a8d49f [project @ 1997-02-18 09:06:10 by jwe]
jwe
parents: 2670
diff changeset
276 gset term postscript
8c7955a8d49f [project @ 1997-02-18 09:06:10 by jwe]
jwe
parents: 2670
diff changeset
277 gset output "foo.ps"
2333
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
278 replot
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
279 @end group
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
280 @end example
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
281
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
282 @noindent
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
283 This will work for other types of output devices as well. Octave's
2689
8c7955a8d49f [project @ 1997-02-18 09:06:10 by jwe]
jwe
parents: 2670
diff changeset
284 @code{gset} command is really just piped to the @code{gnuplot}
2333
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
285 subprocess, so that once you have a plot on the screen that you like,
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
286 you should be able to do something like this to create an output file
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
287 suitable for your graphics printer.
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
288
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
289 Or, you can eliminate the intermediate file by using commands like this
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
290
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
291 @example
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
292 @group
2689
8c7955a8d49f [project @ 1997-02-18 09:06:10 by jwe]
jwe
parents: 2670
diff changeset
293 gset term postscript
8c7955a8d49f [project @ 1997-02-18 09:06:10 by jwe]
jwe
parents: 2670
diff changeset
294 gset output "|lpr -Pname_of_your_graphics_printer"
2333
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
295 replot
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
296 @end group
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
297 @end example
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
298
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
299 @unnumberedsubsec Editing What You Have Typed
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
300
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
301 At the Octave prompt, you can recall, edit, and reissue previous
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
302 commands using Emacs- or vi-style editing commands. The default
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
303 keybindings use Emacs-style commands. For example, to recall the
2670
18192eea4973 [project @ 1997-02-13 18:29:53 by jwe]
jwe
parents: 2653
diff changeset
304 previous command, type @kbd{Control-p} (usually written @kbd{C-p} for
18192eea4973 [project @ 1997-02-13 18:29:53 by jwe]
jwe
parents: 2653
diff changeset
305 short). @kbd{C-p} gets its name from the fact that you type it by
18192eea4973 [project @ 1997-02-13 18:29:53 by jwe]
jwe
parents: 2653
diff changeset
306 holding down @key{CTRL} and then pressing @key{p}. Doing this will
18192eea4973 [project @ 1997-02-13 18:29:53 by jwe]
jwe
parents: 2653
diff changeset
307 normally bring back the previous line of input. @kbd{C-n} will bring up
18192eea4973 [project @ 1997-02-13 18:29:53 by jwe]
jwe
parents: 2653
diff changeset
308 the next line of input, @kbd{C-b} will move the cursor backward on the
18192eea4973 [project @ 1997-02-13 18:29:53 by jwe]
jwe
parents: 2653
diff changeset
309 line, @kbd{C-f} will move the cursor forward on the line, etc.
2333
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
310
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
311 A complete description of the command line editing capability is given
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
312 in this manual in @ref{Command Line Editing}.
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
313
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
314 @unnumberedsubsec Getting Help
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
315
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
316 Octave has an extensive help facility. The same documentation that is
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
317 available in printed form is also available from the Octave prompt,
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
318 because both forms of the documentation are created from the same input
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
319 file.
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
320
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
321 In order to get good help you first need to know the name of the command
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
322 that you want to use. This name of the function may not always be
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
323 obvious, but a good place to start is to just type @code{help}.
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
324 This will show you all the operators, reserved words, functions,
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
325 built-in variables, and function files. You can then get more
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
326 help on anything that is listed by simply including the name as an
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
327 argument to help. For example,
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
328
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
329 @example
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
330 help plot
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
331 @end example
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
332
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
333 @noindent
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
334 will display the help text for the @code{plot} function.
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
335
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
336 Octave sends output that is too long to fit on one screen through a
2689
8c7955a8d49f [project @ 1997-02-18 09:06:10 by jwe]
jwe
parents: 2670
diff changeset
337 pager like @code{less} or @code{more}. Type a @key{RET} to advance one
8c7955a8d49f [project @ 1997-02-18 09:06:10 by jwe]
jwe
parents: 2670
diff changeset
338 line, a @key{SPC} to advance one page, and @key{q} to exit the pager.
2333
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
339
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
340 The part of Octave's help facility that allows you to read the complete
2653
e7908588548a [project @ 1997-02-01 16:53:52 by jwe]
jwe
parents: 2449
diff changeset
341 text of the printed manual from within Octave normally uses a separate
e7908588548a [project @ 1997-02-01 16:53:52 by jwe]
jwe
parents: 2449
diff changeset
342 program called Info. When you invoke Info you will be put into a menu
e7908588548a [project @ 1997-02-01 16:53:52 by jwe]
jwe
parents: 2449
diff changeset
343 driven program that contains the entire Octave manual. Help for using
2670
18192eea4973 [project @ 1997-02-13 18:29:53 by jwe]
jwe
parents: 2653
diff changeset
344 Info is provided in this manual in @ref{Getting Help}.
2333
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
345
2653
e7908588548a [project @ 1997-02-01 16:53:52 by jwe]
jwe
parents: 2449
diff changeset
346 @node Conventions, , Simple Examples, Introduction
e7908588548a [project @ 1997-02-01 16:53:52 by jwe]
jwe
parents: 2449
diff changeset
347 @section Conventions
2333
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
348
2653
e7908588548a [project @ 1997-02-01 16:53:52 by jwe]
jwe
parents: 2449
diff changeset
349 This section explains the notational conventions that are used in this
e7908588548a [project @ 1997-02-01 16:53:52 by jwe]
jwe
parents: 2449
diff changeset
350 manual. You may want to skip this section and refer back to it later.
2333
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
351
2653
e7908588548a [project @ 1997-02-01 16:53:52 by jwe]
jwe
parents: 2449
diff changeset
352 @menu
e7908588548a [project @ 1997-02-01 16:53:52 by jwe]
jwe
parents: 2449
diff changeset
353 * Fonts::
e7908588548a [project @ 1997-02-01 16:53:52 by jwe]
jwe
parents: 2449
diff changeset
354 * Evaluation Notation::
e7908588548a [project @ 1997-02-01 16:53:52 by jwe]
jwe
parents: 2449
diff changeset
355 * Printing Notation::
e7908588548a [project @ 1997-02-01 16:53:52 by jwe]
jwe
parents: 2449
diff changeset
356 * Error Messages::
e7908588548a [project @ 1997-02-01 16:53:52 by jwe]
jwe
parents: 2449
diff changeset
357 * Format of Descriptions::
e7908588548a [project @ 1997-02-01 16:53:52 by jwe]
jwe
parents: 2449
diff changeset
358 @end menu
2333
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
359
2653
e7908588548a [project @ 1997-02-01 16:53:52 by jwe]
jwe
parents: 2449
diff changeset
360 @node Fonts, Evaluation Notation, Conventions, Conventions
e7908588548a [project @ 1997-02-01 16:53:52 by jwe]
jwe
parents: 2449
diff changeset
361 @subsection Fonts
e7908588548a [project @ 1997-02-01 16:53:52 by jwe]
jwe
parents: 2449
diff changeset
362 @cindex fonts
2333
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
363
2653
e7908588548a [project @ 1997-02-01 16:53:52 by jwe]
jwe
parents: 2449
diff changeset
364 Examples of Octave code appear in this font or form: @code{svd (a)}.
e7908588548a [project @ 1997-02-01 16:53:52 by jwe]
jwe
parents: 2449
diff changeset
365 Names that represent arguments or metasyntactic variables appear
2993
91589ab98e37 [project @ 1997-05-21 21:44:54 by jwe]
jwe
parents: 2759
diff changeset
366 in this font or form: @var{first-number}. Commands that you type at the
91589ab98e37 [project @ 1997-05-21 21:44:54 by jwe]
jwe
parents: 2759
diff changeset
367 shell prompt sometimes appear in this font or form:
91589ab98e37 [project @ 1997-05-21 21:44:54 by jwe]
jwe
parents: 2759
diff changeset
368 @samp{octave --no-init-file}. Commands that you type at the Octave
91589ab98e37 [project @ 1997-05-21 21:44:54 by jwe]
jwe
parents: 2759
diff changeset
369 prompt sometimes appear in this font or form: @kbd{foo --bar --baz}.
91589ab98e37 [project @ 1997-05-21 21:44:54 by jwe]
jwe
parents: 2759
diff changeset
370 Specific keys on your keyboard appear in this font or form: @key{ANY}.
2759
99dd10f4eaaf [project @ 1997-02-27 08:59:55 by jwe]
jwe
parents: 2703
diff changeset
371 @cindex any key
2333
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
372
2653
e7908588548a [project @ 1997-02-01 16:53:52 by jwe]
jwe
parents: 2449
diff changeset
373 @node Evaluation Notation, Printing Notation, Fonts, Conventions
e7908588548a [project @ 1997-02-01 16:53:52 by jwe]
jwe
parents: 2449
diff changeset
374 @subsection Evaluation Notation
e7908588548a [project @ 1997-02-01 16:53:52 by jwe]
jwe
parents: 2449
diff changeset
375 @cindex evaluation notation
e7908588548a [project @ 1997-02-01 16:53:52 by jwe]
jwe
parents: 2449
diff changeset
376 @cindex documentation notation
e7908588548a [project @ 1997-02-01 16:53:52 by jwe]
jwe
parents: 2449
diff changeset
377
e7908588548a [project @ 1997-02-01 16:53:52 by jwe]
jwe
parents: 2449
diff changeset
378 In the examples in this manual, results from expressions that you
e7908588548a [project @ 1997-02-01 16:53:52 by jwe]
jwe
parents: 2449
diff changeset
379 evaluate are indicated with @samp{@result{}}. For example,
2333
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
380
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
381 @example
2653
e7908588548a [project @ 1997-02-01 16:53:52 by jwe]
jwe
parents: 2449
diff changeset
382 @group
e7908588548a [project @ 1997-02-01 16:53:52 by jwe]
jwe
parents: 2449
diff changeset
383 sqrt (2)
e7908588548a [project @ 1997-02-01 16:53:52 by jwe]
jwe
parents: 2449
diff changeset
384 @result{} 1.4142
e7908588548a [project @ 1997-02-01 16:53:52 by jwe]
jwe
parents: 2449
diff changeset
385 @end group
2333
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
386 @end example
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
387
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
388 @noindent
2653
e7908588548a [project @ 1997-02-01 16:53:52 by jwe]
jwe
parents: 2449
diff changeset
389 You can read this as ``@code{sqrt (2)} evaluates to 1.4142''.
2333
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
390
2653
e7908588548a [project @ 1997-02-01 16:53:52 by jwe]
jwe
parents: 2449
diff changeset
391 In some cases, matrix values that are returned by expressions are
e7908588548a [project @ 1997-02-01 16:53:52 by jwe]
jwe
parents: 2449
diff changeset
392 displayed like this
2449
31d5588dbb61 [project @ 1996-10-30 22:58:44 by jwe]
jwe
parents: 2333
diff changeset
393
31d5588dbb61 [project @ 1996-10-30 22:58:44 by jwe]
jwe
parents: 2333
diff changeset
394 @example
31d5588dbb61 [project @ 1996-10-30 22:58:44 by jwe]
jwe
parents: 2333
diff changeset
395 @group
2653
e7908588548a [project @ 1997-02-01 16:53:52 by jwe]
jwe
parents: 2449
diff changeset
396 [1, 2; 3, 4] == [1, 3; 2, 4]
e7908588548a [project @ 1997-02-01 16:53:52 by jwe]
jwe
parents: 2449
diff changeset
397 @result{} [ 1, 0; 0, 1 ]
e7908588548a [project @ 1997-02-01 16:53:52 by jwe]
jwe
parents: 2449
diff changeset
398 @end group
e7908588548a [project @ 1997-02-01 16:53:52 by jwe]
jwe
parents: 2449
diff changeset
399 @end example
2449
31d5588dbb61 [project @ 1996-10-30 22:58:44 by jwe]
jwe
parents: 2333
diff changeset
400
2653
e7908588548a [project @ 1997-02-01 16:53:52 by jwe]
jwe
parents: 2449
diff changeset
401 @noindent
e7908588548a [project @ 1997-02-01 16:53:52 by jwe]
jwe
parents: 2449
diff changeset
402 and in other cases, they are displayed like this
e7908588548a [project @ 1997-02-01 16:53:52 by jwe]
jwe
parents: 2449
diff changeset
403
e7908588548a [project @ 1997-02-01 16:53:52 by jwe]
jwe
parents: 2449
diff changeset
404 @example
e7908588548a [project @ 1997-02-01 16:53:52 by jwe]
jwe
parents: 2449
diff changeset
405 @group
e7908588548a [project @ 1997-02-01 16:53:52 by jwe]
jwe
parents: 2449
diff changeset
406 eye (3)
e7908588548a [project @ 1997-02-01 16:53:52 by jwe]
jwe
parents: 2449
diff changeset
407 @result{} 1 0 0
e7908588548a [project @ 1997-02-01 16:53:52 by jwe]
jwe
parents: 2449
diff changeset
408 0 1 0
e7908588548a [project @ 1997-02-01 16:53:52 by jwe]
jwe
parents: 2449
diff changeset
409 0 0 1
2449
31d5588dbb61 [project @ 1996-10-30 22:58:44 by jwe]
jwe
parents: 2333
diff changeset
410 @end group
31d5588dbb61 [project @ 1996-10-30 22:58:44 by jwe]
jwe
parents: 2333
diff changeset
411 @end example
31d5588dbb61 [project @ 1996-10-30 22:58:44 by jwe]
jwe
parents: 2333
diff changeset
412
31d5588dbb61 [project @ 1996-10-30 22:58:44 by jwe]
jwe
parents: 2333
diff changeset
413 @noindent
2653
e7908588548a [project @ 1997-02-01 16:53:52 by jwe]
jwe
parents: 2449
diff changeset
414 in order to clearly show the structure of the result.
e7908588548a [project @ 1997-02-01 16:53:52 by jwe]
jwe
parents: 2449
diff changeset
415
e7908588548a [project @ 1997-02-01 16:53:52 by jwe]
jwe
parents: 2449
diff changeset
416 Sometimes to help describe one expression, another expression is
e7908588548a [project @ 1997-02-01 16:53:52 by jwe]
jwe
parents: 2449
diff changeset
417 shown that produces identical results. The exact equivalence of
e7908588548a [project @ 1997-02-01 16:53:52 by jwe]
jwe
parents: 2449
diff changeset
418 expressions is indicated with @samp{@equiv{}}. For example,
2449
31d5588dbb61 [project @ 1996-10-30 22:58:44 by jwe]
jwe
parents: 2333
diff changeset
419
31d5588dbb61 [project @ 1996-10-30 22:58:44 by jwe]
jwe
parents: 2333
diff changeset
420 @example
2653
e7908588548a [project @ 1997-02-01 16:53:52 by jwe]
jwe
parents: 2449
diff changeset
421 @group
e7908588548a [project @ 1997-02-01 16:53:52 by jwe]
jwe
parents: 2449
diff changeset
422 rot90 ([1, 2; 3, 4], -1)
e7908588548a [project @ 1997-02-01 16:53:52 by jwe]
jwe
parents: 2449
diff changeset
423 @equiv{}
e7908588548a [project @ 1997-02-01 16:53:52 by jwe]
jwe
parents: 2449
diff changeset
424 rot90 ([1, 2; 3, 4], 3)
e7908588548a [project @ 1997-02-01 16:53:52 by jwe]
jwe
parents: 2449
diff changeset
425 @equiv{}
e7908588548a [project @ 1997-02-01 16:53:52 by jwe]
jwe
parents: 2449
diff changeset
426 rot90 ([1, 2; 3, 4], 7)
e7908588548a [project @ 1997-02-01 16:53:52 by jwe]
jwe
parents: 2449
diff changeset
427 @end group
2449
31d5588dbb61 [project @ 1996-10-30 22:58:44 by jwe]
jwe
parents: 2333
diff changeset
428 @end example
31d5588dbb61 [project @ 1996-10-30 22:58:44 by jwe]
jwe
parents: 2333
diff changeset
429
2653
e7908588548a [project @ 1997-02-01 16:53:52 by jwe]
jwe
parents: 2449
diff changeset
430 @node Printing Notation, Error Messages, Evaluation Notation, Conventions
e7908588548a [project @ 1997-02-01 16:53:52 by jwe]
jwe
parents: 2449
diff changeset
431 @subsection Printing Notation
e7908588548a [project @ 1997-02-01 16:53:52 by jwe]
jwe
parents: 2449
diff changeset
432 @cindex printing notation
e7908588548a [project @ 1997-02-01 16:53:52 by jwe]
jwe
parents: 2449
diff changeset
433
e7908588548a [project @ 1997-02-01 16:53:52 by jwe]
jwe
parents: 2449
diff changeset
434 Many of the examples in this manual print text when they are
e7908588548a [project @ 1997-02-01 16:53:52 by jwe]
jwe
parents: 2449
diff changeset
435 evaluated. Examples in this manual indicate printed text with
e7908588548a [project @ 1997-02-01 16:53:52 by jwe]
jwe
parents: 2449
diff changeset
436 @samp{@print{}}. The value that is returned by evaluating the
e7908588548a [project @ 1997-02-01 16:53:52 by jwe]
jwe
parents: 2449
diff changeset
437 expression (here @code{1}) is displayed with @samp{@result{}} and
e7908588548a [project @ 1997-02-01 16:53:52 by jwe]
jwe
parents: 2449
diff changeset
438 follows on a separate line.
2449
31d5588dbb61 [project @ 1996-10-30 22:58:44 by jwe]
jwe
parents: 2333
diff changeset
439
31d5588dbb61 [project @ 1996-10-30 22:58:44 by jwe]
jwe
parents: 2333
diff changeset
440 @example
2653
e7908588548a [project @ 1997-02-01 16:53:52 by jwe]
jwe
parents: 2449
diff changeset
441 @group
e7908588548a [project @ 1997-02-01 16:53:52 by jwe]
jwe
parents: 2449
diff changeset
442 printf ("foo %s\n", "bar")
e7908588548a [project @ 1997-02-01 16:53:52 by jwe]
jwe
parents: 2449
diff changeset
443 @print{} foo bar
e7908588548a [project @ 1997-02-01 16:53:52 by jwe]
jwe
parents: 2449
diff changeset
444 @result{} 1
e7908588548a [project @ 1997-02-01 16:53:52 by jwe]
jwe
parents: 2449
diff changeset
445 @end group
e7908588548a [project @ 1997-02-01 16:53:52 by jwe]
jwe
parents: 2449
diff changeset
446 @end example
e7908588548a [project @ 1997-02-01 16:53:52 by jwe]
jwe
parents: 2449
diff changeset
447
e7908588548a [project @ 1997-02-01 16:53:52 by jwe]
jwe
parents: 2449
diff changeset
448 @node Error Messages, Format of Descriptions, Printing Notation, Conventions
e7908588548a [project @ 1997-02-01 16:53:52 by jwe]
jwe
parents: 2449
diff changeset
449 @subsection Error Messages
e7908588548a [project @ 1997-02-01 16:53:52 by jwe]
jwe
parents: 2449
diff changeset
450 @cindex error message notation
e7908588548a [project @ 1997-02-01 16:53:52 by jwe]
jwe
parents: 2449
diff changeset
451
e7908588548a [project @ 1997-02-01 16:53:52 by jwe]
jwe
parents: 2449
diff changeset
452 Some examples signal errors. This normally displays an error message
e7908588548a [project @ 1997-02-01 16:53:52 by jwe]
jwe
parents: 2449
diff changeset
453 on your terminal. Error messages are shown on a line starting with
2670
18192eea4973 [project @ 1997-02-13 18:29:53 by jwe]
jwe
parents: 2653
diff changeset
454 @code{error:}.
2653
e7908588548a [project @ 1997-02-01 16:53:52 by jwe]
jwe
parents: 2449
diff changeset
455
e7908588548a [project @ 1997-02-01 16:53:52 by jwe]
jwe
parents: 2449
diff changeset
456 @example
2670
18192eea4973 [project @ 1997-02-13 18:29:53 by jwe]
jwe
parents: 2653
diff changeset
457 @group
2653
e7908588548a [project @ 1997-02-01 16:53:52 by jwe]
jwe
parents: 2449
diff changeset
458 struct_elements ([1, 2; 3, 4])
2670
18192eea4973 [project @ 1997-02-13 18:29:53 by jwe]
jwe
parents: 2653
diff changeset
459 error: struct_elements: wrong type argument `matrix'
18192eea4973 [project @ 1997-02-13 18:29:53 by jwe]
jwe
parents: 2653
diff changeset
460 @end group
2449
31d5588dbb61 [project @ 1996-10-30 22:58:44 by jwe]
jwe
parents: 2333
diff changeset
461 @end example
31d5588dbb61 [project @ 1996-10-30 22:58:44 by jwe]
jwe
parents: 2333
diff changeset
462
2653
e7908588548a [project @ 1997-02-01 16:53:52 by jwe]
jwe
parents: 2449
diff changeset
463 @node Format of Descriptions, , Error Messages, Conventions
e7908588548a [project @ 1997-02-01 16:53:52 by jwe]
jwe
parents: 2449
diff changeset
464 @subsection Format of Descriptions
e7908588548a [project @ 1997-02-01 16:53:52 by jwe]
jwe
parents: 2449
diff changeset
465 @cindex description format
e7908588548a [project @ 1997-02-01 16:53:52 by jwe]
jwe
parents: 2449
diff changeset
466
e7908588548a [project @ 1997-02-01 16:53:52 by jwe]
jwe
parents: 2449
diff changeset
467 Functions, commands, and variables are described in this manual in a
e7908588548a [project @ 1997-02-01 16:53:52 by jwe]
jwe
parents: 2449
diff changeset
468 uniform format. The first line of a description contains the name of
e7908588548a [project @ 1997-02-01 16:53:52 by jwe]
jwe
parents: 2449
diff changeset
469 the item followed by its arguments, if any.
e7908588548a [project @ 1997-02-01 16:53:52 by jwe]
jwe
parents: 2449
diff changeset
470 @ifinfo
e7908588548a [project @ 1997-02-01 16:53:52 by jwe]
jwe
parents: 2449
diff changeset
471 The category---function, variable, or whatever---appears at the
e7908588548a [project @ 1997-02-01 16:53:52 by jwe]
jwe
parents: 2449
diff changeset
472 beginning of the line.
e7908588548a [project @ 1997-02-01 16:53:52 by jwe]
jwe
parents: 2449
diff changeset
473 @end ifinfo
e7908588548a [project @ 1997-02-01 16:53:52 by jwe]
jwe
parents: 2449
diff changeset
474 @iftex
e7908588548a [project @ 1997-02-01 16:53:52 by jwe]
jwe
parents: 2449
diff changeset
475 The category---function, variable, or whatever---is printed next to the
e7908588548a [project @ 1997-02-01 16:53:52 by jwe]
jwe
parents: 2449
diff changeset
476 right margin.
e7908588548a [project @ 1997-02-01 16:53:52 by jwe]
jwe
parents: 2449
diff changeset
477 @end iftex
e7908588548a [project @ 1997-02-01 16:53:52 by jwe]
jwe
parents: 2449
diff changeset
478 The description follows on succeeding lines, sometimes with examples.
2449
31d5588dbb61 [project @ 1996-10-30 22:58:44 by jwe]
jwe
parents: 2333
diff changeset
479
2653
e7908588548a [project @ 1997-02-01 16:53:52 by jwe]
jwe
parents: 2449
diff changeset
480 @menu
e7908588548a [project @ 1997-02-01 16:53:52 by jwe]
jwe
parents: 2449
diff changeset
481 * A Sample Function Description::
e7908588548a [project @ 1997-02-01 16:53:52 by jwe]
jwe
parents: 2449
diff changeset
482 * A Sample Command Description::
e7908588548a [project @ 1997-02-01 16:53:52 by jwe]
jwe
parents: 2449
diff changeset
483 * A Sample Variable Description::
e7908588548a [project @ 1997-02-01 16:53:52 by jwe]
jwe
parents: 2449
diff changeset
484 @end menu
e7908588548a [project @ 1997-02-01 16:53:52 by jwe]
jwe
parents: 2449
diff changeset
485
e7908588548a [project @ 1997-02-01 16:53:52 by jwe]
jwe
parents: 2449
diff changeset
486 @node A Sample Function Description, A Sample Command Description, Format of Descriptions, Format of Descriptions
e7908588548a [project @ 1997-02-01 16:53:52 by jwe]
jwe
parents: 2449
diff changeset
487 @subsubsection A Sample Function Description
e7908588548a [project @ 1997-02-01 16:53:52 by jwe]
jwe
parents: 2449
diff changeset
488 @cindex function descriptions
2333
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
489
2653
e7908588548a [project @ 1997-02-01 16:53:52 by jwe]
jwe
parents: 2449
diff changeset
490 In a function description, the name of the function being described
e7908588548a [project @ 1997-02-01 16:53:52 by jwe]
jwe
parents: 2449
diff changeset
491 appears first. It is followed on the same line by a list of parameters.
e7908588548a [project @ 1997-02-01 16:53:52 by jwe]
jwe
parents: 2449
diff changeset
492 The names used for the parameters are also used in the body of the
e7908588548a [project @ 1997-02-01 16:53:52 by jwe]
jwe
parents: 2449
diff changeset
493 description.
2333
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
494
2653
e7908588548a [project @ 1997-02-01 16:53:52 by jwe]
jwe
parents: 2449
diff changeset
495 Here is a description of an imaginary function @code{foo}:
e7908588548a [project @ 1997-02-01 16:53:52 by jwe]
jwe
parents: 2449
diff changeset
496
e7908588548a [project @ 1997-02-01 16:53:52 by jwe]
jwe
parents: 2449
diff changeset
497 @deftypefn {Function} {} foo (@var{x}, @var{y}, @dots{})
e7908588548a [project @ 1997-02-01 16:53:52 by jwe]
jwe
parents: 2449
diff changeset
498 The function @code{foo} subtracts @var{x} from @var{y}, then adds the
e7908588548a [project @ 1997-02-01 16:53:52 by jwe]
jwe
parents: 2449
diff changeset
499 remaining arguments to the result. If @var{y} is not supplied, then the
e7908588548a [project @ 1997-02-01 16:53:52 by jwe]
jwe
parents: 2449
diff changeset
500 number 19 is used by default.
2333
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
501
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
502 @example
2653
e7908588548a [project @ 1997-02-01 16:53:52 by jwe]
jwe
parents: 2449
diff changeset
503 @group
e7908588548a [project @ 1997-02-01 16:53:52 by jwe]
jwe
parents: 2449
diff changeset
504 foo (1, [3, 5], 3, 9)
e7908588548a [project @ 1997-02-01 16:53:52 by jwe]
jwe
parents: 2449
diff changeset
505 @result{} [ 14, 16 ]
e7908588548a [project @ 1997-02-01 16:53:52 by jwe]
jwe
parents: 2449
diff changeset
506 foo (5)
e7908588548a [project @ 1997-02-01 16:53:52 by jwe]
jwe
parents: 2449
diff changeset
507 @result{} 14
e7908588548a [project @ 1997-02-01 16:53:52 by jwe]
jwe
parents: 2449
diff changeset
508 @end group
2333
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
509 @end example
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
510
2653
e7908588548a [project @ 1997-02-01 16:53:52 by jwe]
jwe
parents: 2449
diff changeset
511 More generally,
2333
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
512
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
513 @example
2653
e7908588548a [project @ 1997-02-01 16:53:52 by jwe]
jwe
parents: 2449
diff changeset
514 @group
e7908588548a [project @ 1997-02-01 16:53:52 by jwe]
jwe
parents: 2449
diff changeset
515 foo (@var{w}, @var{x}, @var{y}, @dots{})
e7908588548a [project @ 1997-02-01 16:53:52 by jwe]
jwe
parents: 2449
diff changeset
516 @equiv{}
e7908588548a [project @ 1997-02-01 16:53:52 by jwe]
jwe
parents: 2449
diff changeset
517 @var{x} - @var{w} + @var{y} + @dots{}
e7908588548a [project @ 1997-02-01 16:53:52 by jwe]
jwe
parents: 2449
diff changeset
518 @end group
e7908588548a [project @ 1997-02-01 16:53:52 by jwe]
jwe
parents: 2449
diff changeset
519 @end example
e7908588548a [project @ 1997-02-01 16:53:52 by jwe]
jwe
parents: 2449
diff changeset
520 @end deftypefn
e7908588548a [project @ 1997-02-01 16:53:52 by jwe]
jwe
parents: 2449
diff changeset
521
e7908588548a [project @ 1997-02-01 16:53:52 by jwe]
jwe
parents: 2449
diff changeset
522 Any parameter whose name contains the name of a type (e.g.,
e7908588548a [project @ 1997-02-01 16:53:52 by jwe]
jwe
parents: 2449
diff changeset
523 @var{integer}, @var{integer1} or @var{matrix}) is expected to be of that
e7908588548a [project @ 1997-02-01 16:53:52 by jwe]
jwe
parents: 2449
diff changeset
524 type. Parameters named @var{object} may be of any type. Parameters
e7908588548a [project @ 1997-02-01 16:53:52 by jwe]
jwe
parents: 2449
diff changeset
525 with other sorts of names (e.g., @var{new_file}) are discussed
e7908588548a [project @ 1997-02-01 16:53:52 by jwe]
jwe
parents: 2449
diff changeset
526 specifically in the description of the function. In some sections,
e7908588548a [project @ 1997-02-01 16:53:52 by jwe]
jwe
parents: 2449
diff changeset
527 features common to parameters of several functions are described at the
e7908588548a [project @ 1997-02-01 16:53:52 by jwe]
jwe
parents: 2449
diff changeset
528 beginning.
e7908588548a [project @ 1997-02-01 16:53:52 by jwe]
jwe
parents: 2449
diff changeset
529
e7908588548a [project @ 1997-02-01 16:53:52 by jwe]
jwe
parents: 2449
diff changeset
530 Functions in Octave may be defined in several different ways. The
e7908588548a [project @ 1997-02-01 16:53:52 by jwe]
jwe
parents: 2449
diff changeset
531 catagory name for functions may include another name that indicates the
e7908588548a [project @ 1997-02-01 16:53:52 by jwe]
jwe
parents: 2449
diff changeset
532 way that the function is defined. These additional tags include
e7908588548a [project @ 1997-02-01 16:53:52 by jwe]
jwe
parents: 2449
diff changeset
533
e7908588548a [project @ 1997-02-01 16:53:52 by jwe]
jwe
parents: 2449
diff changeset
534 @table @asis
e7908588548a [project @ 1997-02-01 16:53:52 by jwe]
jwe
parents: 2449
diff changeset
535 @item Built-in Function
2670
18192eea4973 [project @ 1997-02-13 18:29:53 by jwe]
jwe
parents: 2653
diff changeset
536 @cindex built-in function
2653
e7908588548a [project @ 1997-02-01 16:53:52 by jwe]
jwe
parents: 2449
diff changeset
537 The function described is written in a language like C++, C, or Fortran,
e7908588548a [project @ 1997-02-01 16:53:52 by jwe]
jwe
parents: 2449
diff changeset
538 and is part of the compiled Octave binary.
2333
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
539
2653
e7908588548a [project @ 1997-02-01 16:53:52 by jwe]
jwe
parents: 2449
diff changeset
540 @item Loadable Function
2670
18192eea4973 [project @ 1997-02-13 18:29:53 by jwe]
jwe
parents: 2653
diff changeset
541 @cindex loadable function
2653
e7908588548a [project @ 1997-02-01 16:53:52 by jwe]
jwe
parents: 2449
diff changeset
542 The function described is written in a language like C++, C, or Fortran.
e7908588548a [project @ 1997-02-01 16:53:52 by jwe]
jwe
parents: 2449
diff changeset
543 On systems that support dynamic linking of user-supplied functions, it
e7908588548a [project @ 1997-02-01 16:53:52 by jwe]
jwe
parents: 2449
diff changeset
544 may be automatically linked while Octave is running, but only if it is
e7908588548a [project @ 1997-02-01 16:53:52 by jwe]
jwe
parents: 2449
diff changeset
545 needed. @xref{Dynamically Linked Functions}.
e7908588548a [project @ 1997-02-01 16:53:52 by jwe]
jwe
parents: 2449
diff changeset
546
e7908588548a [project @ 1997-02-01 16:53:52 by jwe]
jwe
parents: 2449
diff changeset
547 @item Function File
2670
18192eea4973 [project @ 1997-02-13 18:29:53 by jwe]
jwe
parents: 2653
diff changeset
548 @cindex function file
2653
e7908588548a [project @ 1997-02-01 16:53:52 by jwe]
jwe
parents: 2449
diff changeset
549 The function described is defined using Octave commands stored in a text
e7908588548a [project @ 1997-02-01 16:53:52 by jwe]
jwe
parents: 2449
diff changeset
550 file. @xref{Function Files}.
2689
8c7955a8d49f [project @ 1997-02-18 09:06:10 by jwe]
jwe
parents: 2670
diff changeset
551
8c7955a8d49f [project @ 1997-02-18 09:06:10 by jwe]
jwe
parents: 2670
diff changeset
552 @item Mapping Function
8c7955a8d49f [project @ 1997-02-18 09:06:10 by jwe]
jwe
parents: 2670
diff changeset
553 @cindex mapping function
8c7955a8d49f [project @ 1997-02-18 09:06:10 by jwe]
jwe
parents: 2670
diff changeset
554 The function described works element-by-element for matrix and vector
8c7955a8d49f [project @ 1997-02-18 09:06:10 by jwe]
jwe
parents: 2670
diff changeset
555 arguments.
2653
e7908588548a [project @ 1997-02-01 16:53:52 by jwe]
jwe
parents: 2449
diff changeset
556 @end table
e7908588548a [project @ 1997-02-01 16:53:52 by jwe]
jwe
parents: 2449
diff changeset
557
e7908588548a [project @ 1997-02-01 16:53:52 by jwe]
jwe
parents: 2449
diff changeset
558 @node A Sample Command Description, A Sample Variable Description, A Sample Function Description, Format of Descriptions
2670
18192eea4973 [project @ 1997-02-13 18:29:53 by jwe]
jwe
parents: 2653
diff changeset
559 @subsubsection A Sample Command Description
2653
e7908588548a [project @ 1997-02-01 16:53:52 by jwe]
jwe
parents: 2449
diff changeset
560 @cindex command descriptions
e7908588548a [project @ 1997-02-01 16:53:52 by jwe]
jwe
parents: 2449
diff changeset
561
e7908588548a [project @ 1997-02-01 16:53:52 by jwe]
jwe
parents: 2449
diff changeset
562 Command descriptions have a format similar to function descriptions,
e7908588548a [project @ 1997-02-01 16:53:52 by jwe]
jwe
parents: 2449
diff changeset
563 except that the word `Function' is replaced by `Command. Commands are
2703
41d6a1c814c4 [project @ 1997-02-19 19:25:55 by jwe]
jwe
parents: 2689
diff changeset
564 functions that may called without surrounding their arguments in
2653
e7908588548a [project @ 1997-02-01 16:53:52 by jwe]
jwe
parents: 2449
diff changeset
565 parentheses. For example, here is the description for Octave's
e7908588548a [project @ 1997-02-01 16:53:52 by jwe]
jwe
parents: 2449
diff changeset
566 @code{cd} command:
e7908588548a [project @ 1997-02-01 16:53:52 by jwe]
jwe
parents: 2449
diff changeset
567
e7908588548a [project @ 1997-02-01 16:53:52 by jwe]
jwe
parents: 2449
diff changeset
568 @deffn {Command} cd dir
e7908588548a [project @ 1997-02-01 16:53:52 by jwe]
jwe
parents: 2449
diff changeset
569 @deffnx {Command} chdir dir
e7908588548a [project @ 1997-02-01 16:53:52 by jwe]
jwe
parents: 2449
diff changeset
570 Change the current working directory to @var{dir}. For example,
2670
18192eea4973 [project @ 1997-02-13 18:29:53 by jwe]
jwe
parents: 2653
diff changeset
571 @kbd{cd ~/octave} changes the current working directory to
18192eea4973 [project @ 1997-02-13 18:29:53 by jwe]
jwe
parents: 2653
diff changeset
572 @file{~/octave}. If the directory does not exist, an error message is
18192eea4973 [project @ 1997-02-13 18:29:53 by jwe]
jwe
parents: 2653
diff changeset
573 printed and the working directory is not changed.
2653
e7908588548a [project @ 1997-02-01 16:53:52 by jwe]
jwe
parents: 2449
diff changeset
574 @end deffn
2333
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
575
2653
e7908588548a [project @ 1997-02-01 16:53:52 by jwe]
jwe
parents: 2449
diff changeset
576 @node A Sample Variable Description, , A Sample Command Description, Format of Descriptions
e7908588548a [project @ 1997-02-01 16:53:52 by jwe]
jwe
parents: 2449
diff changeset
577 @subsubsection A Sample Variable Description
e7908588548a [project @ 1997-02-01 16:53:52 by jwe]
jwe
parents: 2449
diff changeset
578 @cindex variable descriptions
2333
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
579
2653
e7908588548a [project @ 1997-02-01 16:53:52 by jwe]
jwe
parents: 2449
diff changeset
580 A @dfn{variable} is a name that can hold a value. Although any variable
2670
18192eea4973 [project @ 1997-02-13 18:29:53 by jwe]
jwe
parents: 2653
diff changeset
581 can be set by the user, @dfn{built-in variables} typically exist
18192eea4973 [project @ 1997-02-13 18:29:53 by jwe]
jwe
parents: 2653
diff changeset
582 specifically so that users can change them to alter the way Octave
18192eea4973 [project @ 1997-02-13 18:29:53 by jwe]
jwe
parents: 2653
diff changeset
583 behaves (built-in variables are also sometimes called @dfn{user
18192eea4973 [project @ 1997-02-13 18:29:53 by jwe]
jwe
parents: 2653
diff changeset
584 options}). Ordinary variables and built-in variables are described
18192eea4973 [project @ 1997-02-13 18:29:53 by jwe]
jwe
parents: 2653
diff changeset
585 using a format like that for functions except that there are no
18192eea4973 [project @ 1997-02-13 18:29:53 by jwe]
jwe
parents: 2653
diff changeset
586 arguments.
2333
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
587
2689
8c7955a8d49f [project @ 1997-02-18 09:06:10 by jwe]
jwe
parents: 2670
diff changeset
588 Here is a description of the imaginary variable
2653
e7908588548a [project @ 1997-02-01 16:53:52 by jwe]
jwe
parents: 2449
diff changeset
589 @code{do_what_i_mean_not_what_i_say}.
2333
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
590
2670
18192eea4973 [project @ 1997-02-13 18:29:53 by jwe]
jwe
parents: 2653
diff changeset
591 @defvr {Built-in Variable} do_what_i_mean_not_what_i_say
2653
e7908588548a [project @ 1997-02-01 16:53:52 by jwe]
jwe
parents: 2449
diff changeset
592 If the value of this variable is nonzero, Octave will do what you
e7908588548a [project @ 1997-02-01 16:53:52 by jwe]
jwe
parents: 2449
diff changeset
593 actually wanted, even if you have typed a completely different and
e7908588548a [project @ 1997-02-01 16:53:52 by jwe]
jwe
parents: 2449
diff changeset
594 meaningless list of commands.
e7908588548a [project @ 1997-02-01 16:53:52 by jwe]
jwe
parents: 2449
diff changeset
595 @end defvr
2333
b1a56412c385 [project @ 1996-07-19 02:20:16 by jwe]
jwe
parents:
diff changeset
596
2670
18192eea4973 [project @ 1997-02-13 18:29:53 by jwe]
jwe
parents: 2653
diff changeset
597 Other variable descriptions have the same format, but `Built-in
18192eea4973 [project @ 1997-02-13 18:29:53 by jwe]
jwe
parents: 2653
diff changeset
598 Variable' is replaced by `Variable', for ordinary variables, or
18192eea4973 [project @ 1997-02-13 18:29:53 by jwe]
jwe
parents: 2653
diff changeset
599 `Constant' for symbolic constants whose values cannot be changed.