2333
|
1 % refcard.tex |
|
2 % |
|
3 % This file is TeX source for a reference card describing Octave. |
|
4 % |
|
5 % John W. Eaton |
|
6 % jwe@che.utexas.edu |
|
7 % Department of Chemical Engineering |
|
8 % The University of Texas at Austin |
|
9 % |
|
10 % Heavily modified by jwe from the source for the gdb reference card, |
|
11 % which was orignally written by Roland Pesch <pesch@cygnus.com>. |
|
12 % |
|
13 % Copyright (C) 1991, 1992 Free Software Foundation, Inc. |
|
14 % Permission is granted to make and distribute verbatim copies of |
|
15 % this reference provided the copyright notices and permission notices |
|
16 % are preserved on all copies. |
|
17 % |
|
18 % TeX markup is a programming language; accordingly this file is source |
|
19 % for a program to generate a reference. |
|
20 % |
|
21 % This program is free software; you can redistribute it and/or modify |
|
22 % it under the terms of the GNU General Public License as published by |
|
23 % the Free Software Foundation; either version 2, or (at your option) |
|
24 % any later version. |
|
25 % |
|
26 % This program is distributed in the hope that it will be useful, but |
|
27 % WITHOUT ANY WARRANTY; without even the implied warranty of |
|
28 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
29 % General Public License for more details. |
|
30 % |
|
31 % You can find a copy of the GNU General Public License in the GDB |
|
32 % manual; or write to the Free Software Foundation, Inc., |
|
33 % 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
|
34 % |
|
35 % You only have to set the total width and height of the paper, the |
|
36 % horizontal and vertical margin space measured from *paper edge* |
|
37 % and the interline and interspec spacing. |
|
38 % In order to support a new papersize, you have to fiddle with the |
|
39 % latter four dimensions. Just try out a few values. |
|
40 % All other values will be computed at process time so it should be |
|
41 % quite easy to support different paper sizes - only four values to |
|
42 % guess :-) |
|
43 % |
|
44 % To find the configuration places, just search for the string |
|
45 % "User configuration". |
|
46 % |
|
47 % -- Andreas Vogel (av@ssw.de) |
|
48 % |
|
49 % NOTE ON INTENTIONAL OMISSIONS: This reference card includes many |
|
50 % Octave commands, but due to space constraints there are some things |
|
51 % I chose to omit. In general, not all synonyms for commands are |
|
52 % covered, nor all variations of a command. |
|
53 |
|
54 \def\octaveversion{1.1.1} |
|
55 \def\refcardedition{1.1} |
|
56 |
|
57 % ------------------ |
|
58 % multicolumn format |
|
59 % ------------------ |
|
60 |
|
61 % Declarations (these must come first) |
|
62 |
|
63 \newdimen\totalwidth |
|
64 \newdimen\totalheight |
|
65 \newdimen\hmargin |
|
66 \newdimen\vmargin |
|
67 \newdimen\secskip |
|
68 \newdimen\lskip |
|
69 \newdimen\barwidth |
|
70 \newdimen\barheight |
|
71 \newdimen\intersecwidth |
|
72 |
|
73 \newcount\columnsperpage |
|
74 |
|
75 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
76 % % |
|
77 % CONFIGURATION % |
|
78 % % |
|
79 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
80 |
|
81 % There are currently 8 total columns, so some of these options will |
|
82 % not create a single page reference card. |
|
83 |
|
84 % Choose a paper size. Default is US letter size. |
|
85 |
|
86 \def\refcardafoursize{a4} % 3 columns, A4 paper (1 in = 254 mm) |
|
87 \def\refcardlegalsize{legal} % 4 columns, US legal paper (8.5 x 14in) |
4893
|
88 \def\refcardlettersize{letter} % 3 columns, US letter paper (8.5 x 11in) |
2333
|
89 |
|
90 \ifx\refcardsize\refcardafoursize |
|
91 \columnsperpage=3 % total number of columns to typeset |
|
92 \totalwidth=297mm % total width of paper |
|
93 \totalheight=210mm % total height of paper |
|
94 \hmargin=9mm % horizontal margin width |
|
95 \vmargin=7mm % vertical margin width |
|
96 \secskip=3mm % space between refcard secs |
|
97 \lskip=0.4mm % extra skip between \sec entries |
|
98 \else |
|
99 \ifx\refcardsize\refcardlegalsize |
|
100 \columnsperpage=4 % total number of columns to typeset |
|
101 \totalwidth=14in % total width of paper |
|
102 \totalheight=8.5in % total height of paper |
|
103 \hmargin=0.20in % horizontal margin width |
|
104 \vmargin=0.25in % vertical margin width |
|
105 \secskip=0.75pc % space between refcard secs |
|
106 \lskip=2pt % extra skip between \sec entries |
|
107 \else |
|
108 \columnsperpage=3 % total number of columns to typeset |
|
109 \totalwidth=11in % total width of paper |
|
110 \totalheight=8.5in % total height of paper |
|
111 \hmargin=0.25in % horizontal margin width |
|
112 \vmargin=0.25in % vertical margin width |
|
113 \secskip=0.75pc % space between refcard secs |
|
114 \lskip=2pt % extra skip between \sec entries |
|
115 \fi |
|
116 \fi |
|
117 |
4489
|
118 \ifx\pdfoutput\undefined |
|
119 \else |
|
120 \pdfpageheight=\totalheight |
4866
|
121 \pdfpagewidth=\totalwidth |
4489
|
122 \fi |
|
123 |
2333
|
124 % Change according to personal taste, not papersize dependent. |
|
125 |
|
126 \barwidth=.1pt % width of the cropmark bar |
|
127 \barheight=2pt % height of the cropmark bar |
|
128 \intersecwidth=0.5em % width between \itmwid and \dfnwid |
|
129 |
|
130 % Uncomment only one of the following definitions for folding guides. |
|
131 |
|
132 % No printed folding guide: |
|
133 |
|
134 %\def\vdecor{\hskip\hmargin plus1fil |
|
135 % \hskip\barwidth plus1fil |
|
136 % \hskip\hmargin plus1fil} |
|
137 |
|
138 % Solid line folding guide: |
|
139 |
|
140 %\def\vdecor{\hskip\hmargin plus1fil% |
|
141 % \vrule width \barwidth% |
|
142 % \hskip\hmargin plus1fil} |
|
143 |
|
144 % For small marks near top and bottom as folding guide: |
|
145 |
|
146 \def\vdecor{\hskip\hmargin plus1fil% |
|
147 \vbox to \vsize{\hbox to \barwidth{\vrule height\barheight width\barwidth}% |
|
148 \vfill |
|
149 \hbox to \barwidth{\vrule height\barheight width\barwidth}}% |
|
150 \hskip\hmargin plus1fil} |
|
151 |
|
152 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
153 % % |
|
154 % END CONFIGURATION % |
|
155 % % |
|
156 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
157 |
|
158 % values to be computed based on above definitions. |
|
159 % nothing to configure |
|
160 |
|
161 \newdimen\fullhsize % width of area without margins |
|
162 \newdimen\itmwid % width of item column |
|
163 \newdimen\dfnwid % width of definition column |
|
164 \newdimen\idnwid % width of indented text |
|
165 \newdimen\temp % only for temporary use |
|
166 |
|
167 % an alternate section format, used in some cases to make text fit better. |
|
168 |
|
169 \newdimen\altitmwid % width of item column in altsec |
|
170 \newdimen\altdfnwid % width of definition column in altsec |
|
171 |
|
172 % Subtract hmargin for left and right sides of paper from full width. |
|
173 % |
|
174 % fullhsize = totalwidth - (2 * hmargin) |
|
175 |
|
176 \fullhsize=\totalwidth |
|
177 \temp=\hmargin |
|
178 \multiply \temp by 2 |
|
179 \advance \fullhsize by -\temp |
|
180 |
|
181 % intercolumn space is composed of hmargin barwidth hmargin so that we |
|
182 % get the same amount of space on either side of the (optional) rule |
|
183 % between columns. For N columns, we need to subtract this amount of |
|
184 % space N-1 times. Divide by the number of columns to get the final |
|
185 % value of \hsize that we use to typeset columns. |
|
186 |
|
187 % hsize = (fullhsize - (ncols-1)*barwidth - 2*(ncols-1)*hmargin) / ncols |
|
188 |
|
189 \newcount\tmpcnt |
|
190 \tmpcnt\columnsperpage |
|
191 \advance \tmpcnt by -1 |
|
192 |
|
193 \hsize=\fullhsize |
|
194 |
|
195 \temp=\barwidth |
|
196 \multiply \temp by \tmpcnt |
|
197 \advance \hsize by -\temp |
|
198 |
|
199 \multiply \tmpcnt by 2 |
|
200 |
|
201 \temp=\hmargin |
|
202 \multiply \temp by \tmpcnt |
|
203 \advance \hsize by -\temp |
|
204 |
|
205 \divide \hsize by \columnsperpage |
|
206 |
|
207 % Vertical size is easy -- same amount of space above and below. |
|
208 % |
|
209 % vsize = totalheight - (2 * vmargin) |
|
210 |
|
211 \vsize=\totalheight |
|
212 \temp=\vmargin |
|
213 \multiply \temp by 2 |
|
214 \advance \vsize by -\temp |
|
215 |
|
216 % adjust the offsets so the margins are measured *from paper edge* |
|
217 |
|
218 \hoffset=-1in \advance \hoffset by \hmargin |
|
219 \voffset=-1in \advance \voffset by \vmargin |
|
220 |
|
221 % Width of items in a section. |
|
222 |
|
223 % itmwid = (hsize - intersecwidth) * 1/3 |
|
224 % dfnwid = (hsize - intersecwidth) * 2/3 |
|
225 |
|
226 % width of the item |
|
227 |
|
228 \temp=\hsize |
|
229 \advance \temp by -\intersecwidth |
|
230 \divide \temp by 3 |
|
231 \itmwid=\temp |
|
232 |
|
233 % width of the corresponding definition |
|
234 |
|
235 \dfnwid=\hsize |
|
236 \advance \dfnwid by -\itmwid |
|
237 |
|
238 % indentation for sub items, etc. |
|
239 |
|
240 \temp=\hsize \advance\temp by -1em |
|
241 \idnwid=\temp |
|
242 |
|
243 % Width of items in an alt section. |
|
244 |
|
245 \altitmwid=\itmwid \advance \altitmwid by 0.35in |
|
246 \altdfnwid=\dfnwid \advance \altdfnwid by -0.35in |
|
247 |
|
248 % Output macros. |
|
249 % |
|
250 % Strategy: |
|
251 % |
|
252 % * set each column in a box |
|
253 % * append new columns in a global `holding' box, inserting |
|
254 % intercolumn decorations as necessary. |
|
255 % * when we fill a page, dump the saved box and the latest column, |
|
256 % separated by the intercolumn decoration. |
|
257 |
|
258 \newbox\holdbox |
|
259 \newcount\colno |
|
260 \colno=0 |
|
261 |
|
262 \output={\relax |
|
263 \global\advance\colno by 1 |
|
264 \ifnum\colno=1 |
|
265 \global\setbox\holdbox=\columnbox |
|
266 \else |
|
267 \ifnum\colno=\columnsperpage |
|
268 \shipout\hbox to \fullhsize{\box\holdbox\vdecor\columnbox} |
|
269 \advancepageno |
|
270 \global\colno=0 |
|
271 \else |
|
272 \global\setbox\holdbox=\vbox{\hbox{\box\holdbox\vdecor\columnbox}} |
|
273 \fi |
|
274 \fi} |
|
275 |
|
276 \def\columnbox{\leftline{\pagebody}} |
|
277 |
|
278 \def\bye{\par\vfill |
|
279 \supereject |
|
280 \if R\lcr \null\vfill\eject \fi |
|
281 \end} |
|
282 |
|
283 % ----- |
|
284 % Fonts |
|
285 % ----- |
|
286 |
|
287 \font\bbf=cmbx10 |
|
288 \font\vbbf=cmbx12 |
|
289 \font\smrm=cmr6 |
|
290 \font\brm=cmr10 |
|
291 \font\rm=cmr7 |
|
292 \font\it=cmti7 |
|
293 \font\tt=cmtt8 |
|
294 |
|
295 % We can afford to allow some slop |
|
296 |
|
297 \hfuzz=1pt |
|
298 \vfuzz=1pt |
|
299 \hyphenpenalty=5000 |
|
300 \tolerance=2000 |
|
301 \raggedright |
|
302 \raggedbottom |
|
303 \normalbaselineskip=9pt |
|
304 \baselineskip=9pt |
|
305 |
|
306 \parindent=0pt |
|
307 \parskip=0pt |
|
308 \footline={\vbox to0pt{\hss}} |
|
309 |
|
310 \def\ctl#1{{\tt C-#1}} |
|
311 \def\opt#1{{\brm[{\rm #1}]}} |
|
312 \def\xtra#1{\noalign{\smallskip{\tt#1}}} |
|
313 |
|
314 % A normal section |
|
315 |
|
316 \long\def\sec#1;#2\endsec{\vskip \secskip |
|
317 \halign{% |
|
318 % |
|
319 % column 1 (of halign): |
|
320 % |
|
321 \vtop{\hsize=\itmwid\tt ##\par\vskip \lskip }\hfil |
|
322 % |
|
323 % column 2 (of halign): |
|
324 % |
|
325 &\vtop{% |
|
326 \hsize=\dfnwid |
|
327 \hangafter=1 |
|
328 \hangindent=\intersecwidth |
|
329 \rm ##\par\vskip \lskip}\cr |
|
330 % |
|
331 % Tail of \long\def fills in halign body with \sec args: |
|
332 % |
|
333 \noalign{{\bbf #1}% |
|
334 \vskip \lskip} |
|
335 #2}} |
|
336 |
|
337 \long\def\widesec#1;#2\endsec{\vskip \secskip |
|
338 \halign{% |
|
339 % |
|
340 % column 1 (of halign): |
|
341 % |
|
342 \vbox{\tt |
|
343 ##\par\vskip \lskip }\cr |
|
344 % |
|
345 % Tail of \long\def fills in halign body with \sec args: |
|
346 % |
|
347 \noalign{{\bbf #1}\vskip 3\lskip} |
|
348 #2}} |
|
349 |
|
350 % an alternate section format, used in some cases to make text fit better. |
|
351 |
|
352 \long\def\altsec#1;#2\endsec{\vskip \secskip |
|
353 \halign{% |
|
354 % |
|
355 % column 1 (of halign): |
|
356 % |
|
357 \vtop{\hsize=\altitmwid\tt |
|
358 ##\par\vskip \lskip}\hfil |
|
359 % |
|
360 % column 2 (of halign): |
|
361 % |
|
362 &\vtop{% |
|
363 \hsize=\altdfnwid |
|
364 \hangafter=1 |
|
365 \hangindent=\intersecwidth |
|
366 \rm ##\par\vskip \lskip}\cr |
|
367 % |
|
368 % Tail of \long\def fills in halign body with \sec args: |
|
369 % |
|
370 \noalign{{\bbf #1}\vskip \lskip} |
|
371 #2}} |
|
372 |
|
373 % ------------------------------------- |
|
374 % The actual text of the reference card |
|
375 % ------------------------------------- |
|
376 |
|
377 {\vbbf Octave Quick Reference}\hfil{\smrm Octave Version \octaveversion}\qquad |
|
378 |
|
379 \sec Starting Octave; |
|
380 octave&start interactive Octave session\cr |
|
381 octave {\it file}&run Octave on commands in {\it file}\cr |
|
382 octave --help&describe command line options\cr |
|
383 \endsec |
|
384 |
|
385 \sec Stopping Octave; |
|
386 quit {\rm or} exit&exit Octave\cr |
|
387 INTERRUPT&({\it e.g.} \ctl{c}) terminate current command and return to |
|
388 top-level prompt\cr |
|
389 \endsec |
|
390 |
|
391 \sec Getting Help; |
|
392 help&list all commands and built-in variables\cr |
|
393 help {\it command}&briefly describe {\it command}\cr |
|
394 help -i&use Info to browse Octave manual\cr |
|
395 help -i {\it command}&search for {\it command\/} in Octave manual\cr |
|
396 \endsec |
|
397 |
|
398 \sec Motion in Info; |
|
399 SPC {\rm or} C-v&scroll forward one screenful\cr |
|
400 DEL {\rm or} M-v&scroll backward one screenful\cr |
|
401 C-l&redraw the display\cr |
|
402 \endsec |
|
403 |
|
404 \sec Node Selection in Info; |
|
405 n&select the next node\cr |
|
406 p&select the previous node\cr |
|
407 u&select the `up' node\cr |
|
408 t&select the `top' node\cr |
|
409 d&select the directory node\cr |
|
410 <&select the first node in the current file\cr |
|
411 >&select the last node in the current file\cr |
|
412 % ]&move forward through the node structure\cr |
|
413 % [&move backward through the nodes\cr |
|
414 g&reads the name of a node and selects it\cr |
|
415 C-x k&kills the current node\cr |
|
416 \endsec |
|
417 |
|
418 \sec Searching in Info; |
|
419 s&search for a string\cr |
|
420 C-s&search forward incrementally\cr |
|
421 C-r&search backward incrementally\cr |
|
422 i&search index \& go to corresponding node\cr |
|
423 ,&go to next match from last `i' command\cr |
|
424 \endsec |
|
425 |
|
426 \sec Command-Line Cursor Motion; |
|
427 C-b&move back one character\cr |
|
428 C-f&move forward one character\cr |
|
429 C-a&move the the start of the line\cr |
|
430 C-e&move to the end of the line\cr |
|
431 M-f&move forward a word\cr |
|
432 M-b&move backward a word\cr |
|
433 C-l&clear screen, reprinting current line at top\cr |
|
434 \endsec |
|
435 |
|
436 \sec Inserting or Changing Text; |
|
437 M-TAB&insert a tab character\cr |
|
438 DEL&delete character to the left of the cursor\cr |
|
439 C-d&delete character under the cursor\cr |
|
440 C-v&add the next character verbatim\cr |
|
441 C-t&transpose characters at the point\cr |
|
442 M-t&transpose words at the point\cr |
|
443 % M-u&uppercase the current word\cr |
|
444 % M-l&lowercase the current word\cr |
|
445 % M-c&capitalize the current word\cr |
|
446 \endsec |
|
447 |
|
448 \vfill |
|
449 \line{\smrm \opt{ } surround optional arguments |
|
450 \hfill ... show one or more arguments} |
|
451 \vskip0.25\baselineskip |
2847
|
452 \centerline{\smrm Copyright 1996, 1997 John W. Eaton\qquad Permissions on back} |
2333
|
453 \eject |
|
454 |
|
455 \sec Killing and Yanking; |
|
456 C-k&kill to the end of the line\cr |
|
457 C-y&yank the most recently killed text\cr |
|
458 M-d&kill to the end of the current word\cr |
|
459 M-DEL&kill the word behind the cursor\cr |
|
460 M-y&rotate the kill ring and yank the new top\cr |
|
461 \endsec |
|
462 |
|
463 \sec Command Completion and History; |
|
464 TAB&complete a command or variable name\cr |
|
465 M-?&list possible completions\cr |
|
466 |
|
467 RET&enter the current line \cr |
|
468 C-p&move `up' through the history list\cr |
|
469 C-n&move `down' through the history list\cr |
|
470 M-<&move to the first line in the history\cr |
|
471 M->&move to the last line in the history\cr |
|
472 C-r&search backward in the history list\cr |
|
473 C-s&search forward in the history list\cr |
|
474 |
|
475 history \opt{{-q}} \opt{{\it N\/}}&list {\it N\/} previous history lines, |
|
476 omitting history numbers if {\tt -q}\cr |
|
477 history -w \opt{{\it file}}&write history to {\it file\/} ({\tt |
|
478 \char'0176/.octave\_hist} if no {\it file\/} argument)\cr |
|
479 history -r \opt{{\it file}}&read history from {\it file\/} ({\tt |
|
480 \char'0176/.octave\_hist} if no {\it file\/} argument)\cr |
|
481 |
|
482 edit\_history {\it lines}&edit and then run previous |
|
483 commands from the history list\cr |
|
484 run\_history {\it lines}&run previous commands from the |
|
485 history list\cr |
|
486 \quad\opt{{\it beg\/}} \opt{{\it end\/}}&Specify the first and last |
|
487 history commands to edit or run.\cr |
|
488 \omit\hfill\vbox{\hsize=\idnwid\rm\vskip0.25ex |
|
489 If {\it beg}\/ is greater than {\it end}, |
|
490 reverse the list of commands before editing. If {\it end\/} is |
|
491 omitted, select commands from {\it beg\/} to the end of the history |
|
492 list. If both arguments are omitted, edit the previous item in the |
|
493 history list.}\span\cr |
|
494 \endsec |
|
495 |
|
496 \sec Shell Commands; |
|
497 cd {\it dir}&change working directory to {\it dir}\cr |
|
498 pwd&print working directory\cr |
|
499 ls \opt{{\it options}}&print directory listing\cr |
|
500 getenv ({\it string})&return value of named environment variable\cr |
|
501 system ({\it cmd})&execute arbitrary shell command string\cr |
|
502 \endsec |
|
503 |
|
504 \sec Matrices; |
|
505 \omit\vbox{\rm\vskip0.25ex |
|
506 Square brackets delimit literal matrices. Commas separate elements |
|
507 on the same row. Semicolons separate rows. Commas may be replaced |
|
508 by spaces, and semicolons may be replaced by one or more newlines. |
|
509 Elements of a matrix may be arbitrary expressions, provided that |
|
510 all the dimensions agree.\vskip0.75ex}\span\cr |
|
511 [ {\it x}, {\it y}, ... ]&enter a row vector\cr |
|
512 [ {\it x}; {\it y}; ... ]&enter a column vector\cr |
|
513 [ {\it w}, {\it x}; {\it y}, {\it z} ]&enter a 2$\times$2 matrix\cr |
|
514 \endsec |
|
515 |
|
516 \sec Ranges; |
|
517 {\it base} : {\it limit}\cr |
|
518 {\it base} : {\it incr} : {\it limit}\cr |
|
519 \omit\hfill\vbox{\hsize=\idnwid\rm\vskip0.75ex |
|
520 Specify a range of values beginning with {\it base\/} with no elements |
|
521 greater than {\it limit}. If it is omitted, the default value of |
|
522 {\it incr\/} is 1. Negative increments are permitted.}\span\cr |
|
523 \endsec |
|
524 |
|
525 \vfill\eject |
|
526 |
|
527 \sec Strings and Common Escape Sequences; |
|
528 \omit\vbox{\rm\vskip0.5ex |
|
529 A {\it string constant\/} consists of a sequence of characters |
|
530 enclosed in either double-quote or single-quote marks.\vskip0.75ex}\span\cr |
|
531 \char'134\char'134&a literal backslash\cr |
|
532 \char'134 "&a literal double-quote character\cr |
|
533 \char'134 '&a literal single-quote character\cr |
|
534 \char'134 n&newline, ASCII code 10\cr |
|
535 \char'134 t&horizontal tab, ASCII code 9\cr |
|
536 \endsec |
|
537 |
|
538 \sec Index Expressions; |
|
539 {\it var} ({\it idx})&select elements of a vector\cr |
|
540 {\it var} ({\it idx1}, {\it idx2})&select elements of a matrix\cr |
|
541 |
|
542 \quad {\it scalar}&select row (column) corresponding to {\it scalar}\cr |
|
543 \quad {\it vector}&select rows (columns) corresponding to the elements |
|
544 of {\it vector}\cr |
|
545 \quad {\it range}&select rows (columns) corresponding to the elements |
|
546 of {\it range}\cr |
|
547 \quad :&select all rows (columns)\cr |
|
548 \endsec |
|
549 |
|
550 \sec Global Variables; |
|
551 global {\it var1} ...&Declare variables global.\cr |
|
552 \omit\hfill\vbox{\hsize=\idnwid\rm\vskip0.25ex |
|
553 Global variables may be accessed inside the body of a function |
|
554 without having to be passed in the function parameter list provided |
|
555 they are also declared global within the function.}\span\cr |
|
556 \endsec |
|
557 |
|
558 \sec Selected Built-in Variables; |
|
559 EDITOR&editor to use with {\tt edit\_history}\cr |
|
560 Inf, NaN&IEEE infinity, NaN\cr |
|
561 LOADPATH&path to search for function files\cr |
|
562 PAGER&program to use to paginate output\cr |
|
563 ans&last result not explicitly assigned\cr |
|
564 eps&machine precision\cr |
|
565 pi&$\pi$\cr |
|
566 realmax&maximum representable value\cr |
|
567 realmin&minimum representable value\cr |
|
568 \endsec |
|
569 \vskip -\secskip |
|
570 \vskip -2\lskip |
|
571 \altsec \null; |
|
572 automatic\_replot&automatically redraw plots\cr |
|
573 do\_fortran\_indexing&Fortran-style indexing of matrices\cr |
|
574 implicit\_str\_to\_num\_ok&allow strings to become numbers\cr |
|
575 output\_max\_field\_width&maximum numeric field width\cr |
|
576 output\_precision&min significant figures displayed\cr |
|
577 page\_screen\_output&control whether output is paged\cr |
|
578 prefer\_column\_vectors&create column vectors by default\cr |
|
579 resize\_on\_range\_error&automatic resizing of matrices\cr |
|
580 save\_precision&digits stored by {\tt save} command\cr |
|
581 silent\_functions&suppress output from functions\cr |
|
582 warn\_divide\_by\_zero&suppress divide by zero errors\cr |
|
583 \endsec |
|
584 \vskip -\secskip |
|
585 \vskip -2\lskip |
|
586 \widesec \null; |
|
587 commas\_in\_literal\_matrix\vskip\lskip\cr |
|
588 \omit\hfill\vbox{\hsize=\idnwid\rm |
|
589 control handling of spaces in matrices\vskip3\lskip}\cr |
|
590 ignore\_function\_time\_stamp\cr |
|
591 \omit\hfill\vbox{\hsize=\idnwid\rm |
|
592 ignore changes in function files during session\vskip3\lskip}\cr |
|
593 ok\_to\_lose\_imaginary\_part\cr |
|
594 \omit\hfill\vbox{\hsize=\idnwid\rm |
|
595 allow complex to real conversion\vskip3\lskip}\cr |
|
596 prefer\_zero\_one\_indexing\cr |
|
597 \omit\hfill\vbox{\hsize=\idnwid\rm |
|
598 if ambiguous, prefer 0-1 style indexing\vskip3\lskip}\cr |
|
599 \endsec |
|
600 |
|
601 \vfill\eject |
|
602 |
|
603 \sec Arithmetic and Increment Operators; |
|
604 {\it x} + {\it y}&addition\cr |
|
605 {\it x} - {\it y}&subtraction\cr |
|
606 {\it x} * {\it y}&matrix multiplication\cr |
|
607 {\it x} .* {\it y}&element by element multiplication\cr |
|
608 {\it x} / {\it y}&right division, conceptually equivalent to |
|
609 {\tt (inverse~(y')~*~x')'}\cr |
|
610 {\it x} ./ {\it y}&element by element right division\cr |
|
611 {\it x} \char'134{} {\it y}&left division, conceptually equivalent to |
|
612 {\tt inverse~(x)~*~y}\cr |
|
613 {\it x} .\char'134{} {\it y}&element by element left division\cr |
|
614 {\it x} \char'136{} {\it y}&power operator\cr |
|
615 {\it x} .\char'136{} {\it y}&element by element power operator\cr |
|
616 - {\it x}&negation\cr |
|
617 + {\it x}&unary plus (a no-op)\cr |
|
618 {\it x} '&complex conjugate transpose\cr |
|
619 {\it x} .'&transpose\cr |
|
620 ++ {\it x}\quad{\rm(}-- {\it x}{\rm)}&increment (decrement) {\it x}, |
|
621 return {\it new\/} value\cr |
|
622 {\it x} ++\quad{\rm(}{\it x} --{\rm)}&increment (decrement) {\it x}, |
|
623 return {\it old\/} value\cr |
|
624 \endsec |
|
625 |
|
626 \sec Assignment Expressions; |
|
627 {\it var} = {\it expr}&assign expression to variable\cr |
|
628 {\it var} ({\it idx}) = {\it expr}&assign expression to indexed variable\cr |
|
629 \endsec |
|
630 |
|
631 \sec Comparison and Boolean Operators; |
|
632 \omit \vbox{\rm\vskip0.75ex |
|
633 These operators work on an element-by-element basis. Both arguments |
|
634 are always evaluated.\vskip0.75ex}\span\cr |
|
635 {\it x} < {\it y}&true if {\it x\/} is less than {\it y}\cr |
|
636 {\it x} <= {\it y}&true if {\it x\/} is less than or equal to {\it y}\cr |
3602
|
637 {\it x} == {\it y}&true if {\it x\/} is equal to {\it y}\cr |
2333
|
638 {\it x} >= {\it y}&true if {\it x\/} is greater than or equal to {\it y}\cr |
3602
|
639 {\it x} > {\it y}&true if {\it x\/} is greater than {\it y}\cr |
2333
|
640 {\it x} != {\it y}&true if {\it x\/} is not equal to {\it y}\cr |
|
641 {\it x} \& {\it y}&true if both {\it x\/} and {\it y\/} are true\cr |
|
642 {\it x} | {\it y}&true if at least one of {\it x\/} or {\it y\/} is true\cr |
3602
|
643 ! {\it bool}&true if {\it bool\/} is false\cr |
2333
|
644 \endsec |
|
645 |
|
646 \sec Short-circuit Boolean Operators; |
|
647 \omit \vbox{\rm\vskip0.75ex |
|
648 Operators evaluate left-to-right, expecting scalar operands. |
|
649 Operands are only evaluated if necessary, stopping once overall |
|
650 truth value can be determined. Operands are converted to scalars by |
|
651 applying the {\tt all} function.\vskip0.75ex}\span\cr |
|
652 {\it x} \&\& {\it y}&true if both {\it x\/} and {\it y\/} are true\cr |
|
653 {\it x} || {\it y}&true if at least one of {\it x\/} or {\it y\/} is true\cr |
|
654 \endsec |
|
655 |
|
656 \sec Operator Precedence; |
|
657 \omit \vbox{\rm\vskip0.5ex |
|
658 Here is a table of the operators in Octave, in order of increasing |
|
659 precedence.\vskip0.75ex}\span\cr |
|
660 ;\ \ ,&statement separators\cr |
|
661 =&assignment, groups left to right\cr |
|
662 ||\ \ \&\&&logical ``or'' and ``and''\cr |
|
663 |\ \ \&&element-wise ``or'' and ``and''\cr |
|
664 < <= == >= > !=&relational operators\cr |
|
665 :&colon\cr |
|
666 +\ \ -&addition and subtraction\cr |
|
667 * / \char'134\ \ .*\ \ ./\ \ .\char'134&multiplication and division\cr |
|
668 '\ \ .'&transpose\cr |
|
669 +\ \ -\ \ ++\ \ --\ \ !&unary minus, increment, logical ``not''\cr |
|
670 \char'136\ \ .\char'136&exponentiation\cr |
|
671 \endsec |
|
672 |
|
673 \vfill\eject |
|
674 |
|
675 \widesec Statements; |
|
676 for {\it identifier} = {\it expr} {\it stmt-list} endfor\cr |
|
677 \hfill\vbox{\hsize=\idnwid\rm\vskip0.25ex |
|
678 Execute {\it stmt-list} once for each column of {\it expr}. The |
|
679 variable {\it identifier} is set to the value of the current column |
|
680 during each iteration.}\cr\cr |
|
681 while ({\it condition}) {\it stmt-list} endwhile\cr |
|
682 \hfill\vbox{\hsize=\idnwid\rm\vskip0.25ex |
|
683 Execute {\it stmt-list} while {\it condition} is true.}\cr\cr |
|
684 \hbox{\vtop{\hsize=\itmwid\tt break} |
|
685 \vtop{\hsize=\dfnwid\rm exit innermost loop}}\cr |
|
686 \hbox{\vtop{\hsize=\itmwid\tt continue} |
|
687 \vtop{\hsize=\dfnwid\rm go to beginning of innermost loop}}\cr |
|
688 \hbox{\vtop{\hsize=\itmwid\tt return} |
|
689 \vtop{\hsize=\dfnwid\rm return to calling function}}\cr\cr |
|
690 if ({\it condition}) {\it if-body} \opt{{\tt else} {\it else-body}} endif\cr |
|
691 \hfill\vbox{\hsize=\idnwid\rm\vskip0.25ex |
|
692 Execute {\it if-body} if {\it condition} is true, otherwise execute |
|
693 {\it else-body}.}\cr |
|
694 if ({\it condition}) {\it if-body} \opt{{\tt elseif} ({\it condition}) |
|
695 {\it elseif-body}} endif\cr |
|
696 \hfill\vbox{\hsize=\idnwid\rm\vskip0.25ex |
|
697 Execute {\it if-body} if {\it condition} is true, otherwise execute |
|
698 the {\it elseif-body} corresponding to the first {\tt elseif} |
|
699 condition that is true, otherwise execute {\it else-body}.}\cr |
|
700 \hfill\vbox{\hsize=\idnwid\rm\vskip0.25ex |
|
701 Any number of {\tt elseif} clauses may appear in an {\tt if} |
|
702 statement.}\cr\cr |
|
703 unwind\_protect {\it body} unwind\_protect\_cleanup {\it cleanup} end\cr |
|
704 \hfill\vbox{\hsize=\idnwid\rm\vskip0.25ex |
|
705 Execute {\it body}. Execute {\it cleanup} no matter how control |
|
706 exits {\it body}.}\cr |
|
707 \endsec |
|
708 |
|
709 \widesec Defining Functions; |
|
710 function \opt{{\it ret-list}} {\it function-name} |
|
711 \opt{\hskip0.2em({\it arg-list})\hskip0.2em}\cr |
|
712 \quad{\it function-body}\cr |
|
713 endfunction\cr\cr |
|
714 {\rm {\it ret-list\/} may be a single identifier or a comma-separated |
|
715 list of identifiers delimited by square-brackets.\vskip0.75ex}\cr |
|
716 {\rm {\it arg-list\/} is a comma-separated list of identifiers and may |
|
717 be empty.}\cr |
|
718 \endsec |
|
719 |
|
720 \sec Basic Matrix Manipulations; |
|
721 rows ({\it a})&return number of rows of {\it a}\cr |
|
722 columns ({\it a})&return number of columns of {\it a}\cr |
|
723 all ({\it a})&check if all elements of {\it a\/} nonzero\cr |
|
724 any ({\it a})&check if any elements of {\it a\/} nonzero\cr |
|
725 find ({\it a})&return indices of nonzero elements\cr |
|
726 sort ({\it a})&order elements in each column of {\it a}\cr |
|
727 sum ({\it a})&sum elements in columns of {\it a}\cr |
|
728 prod ({\it a})&product of elements in columns of {\it a}\cr |
|
729 min ({\it args})&find minimum values\cr |
|
730 max ({\it args})&find maximum values\cr |
|
731 rem ({\it x}, {\it y})&find remainder of {\it x}/{\it y}\cr |
|
732 reshape ({\it a}, {\it m}, {\it n})&reformat {\it a} to be {\it m} by |
|
733 {\it n}\cr\cr |
|
734 diag ({\it v}, {\it k})&create diagonal matrices\cr |
|
735 linspace ({\it b}, {\it l}, {\it n})&create vector of linearly-spaced |
|
736 elements\cr |
|
737 logspace ({\it b}, {\it l}, {\it n})&create vector of log-spaced |
|
738 elements\cr |
|
739 eye ({\it n}, {\it m})&create {\it n\/} by {\it m\/} identity matrix\cr |
|
740 ones ({\it n}, {\it m})&create {\it n\/} by {\it m\/} matrix of ones\cr |
|
741 zeros ({\it n}, {\it m})&create {\it n\/} by {\it m\/} matrix of zeros\cr |
|
742 rand ({\it n}, {\it m})&create {\it n\/} by {\it m\/} matrix of random |
|
743 values\cr |
|
744 \endsec |
|
745 |
|
746 \vfill\eject |
|
747 |
|
748 % sin({\it a}) cos({\it a}) tan({\it a})&trigonometric functions\cr |
|
749 % asin({\it a}) acos({\it a}) atan({\it a})&inverse trigonometric functions\cr |
|
750 % sinh({\it a}) cosh({\it a}) tanh({\it a})&hyperbolic trig functions\cr |
|
751 % asinh({\it a}) acosh({\it a}) atanh({\it a})&inverse hyperbolic trig |
|
752 % functions\cr\cr |
|
753 |
|
754 \sec Linear Algebra; |
|
755 chol ({\it a})&Cholesky factorization\cr |
|
756 det ({\it a})&compute the determinant of a matrix\cr |
|
757 eig ({\it a})&eigenvalues and eigenvectors\cr |
|
758 expm ({\it a})&compute the exponential of a matrix\cr |
|
759 hess ({\it a})&compute Hessenberg decomposition\cr |
|
760 inverse ({\it a})&invert a square matrix\cr |
|
761 norm ({\it a}, {\it p})&compute the {\it p}-norm of a matrix\cr |
|
762 pinv ({\it a})&compute pseudoinverse of {\it a}\cr |
|
763 qr ({\it a})&compute the QR factorization of a matrix\cr |
|
764 rank ({\it a})&matrix rank\cr |
|
765 schur ({\it a})&Schur decomposition of a matrix\cr |
|
766 svd ({\it a})&singular value decomposition\cr |
|
767 syl ({\it a}, {\it b}, {\it c})&solve the Sylvester equation\cr |
|
768 \endsec |
|
769 |
|
770 \sec Equations, ODEs, DAEs, Quadrature; |
|
771 *fsolve&solve nonlinear algebraic equations\cr |
|
772 *lsode&integrate nonlinear ODEs\cr |
|
773 *dassl&integrate nonlinear DAEs\cr |
|
774 *quad&integrate nonlinear functions\cr\cr |
|
775 perror ({\it nm}, {\it code})&for functions that return numeric |
|
776 codes, print error message for named function and given error |
|
777 code\cr\cr |
|
778 \omit \vbox{\rm |
|
779 {\tt *} See the on-line or printed manual for the complete list of |
|
780 arguments for these functions.}\span\cr |
|
781 \endsec |
|
782 |
|
783 \sec Signal Processing; |
|
784 fft ({\it a})&Fast Fourier Transform using FFTPACK\cr |
|
785 ifft ({\it a})&inverse FFT using FFTPACK\cr |
|
786 freqz ({\it args})&FIR filter frequency response\cr |
|
787 sinc ({\it x})&returns {\tt sin ($\pi$ x)/($\pi$ x)}\cr |
|
788 \endsec |
|
789 |
|
790 \altsec Image Processing; |
|
791 colormap ({\it map})&set the current colormap\cr |
|
792 gray2ind ({\it i}, {\it n})&convert gray scale to Octave image\cr |
|
793 image ({\it img}, {\it zoom})&display an Octave image matrix\cr |
|
794 imagesc ({\it img}, {\it zoom})&display scaled matrix as image\cr |
|
795 imshow ({\it img}, {\it map})&display Octave image\cr |
|
796 imshow ({\it i}, {\it n})&display gray scale image\cr |
|
797 imshow ({\it r}, {\it g}, {\it b})&display RGB image\cr |
|
798 ind2gray ({\it img}, {\it map})&convert Octave image to gray scale\cr |
|
799 ind2rgb ({\it img}, {\it map})&convert indexed image to RGB\cr |
|
800 loadimage ({\it file})&load an image file\cr |
|
801 rgb2ind ({\it r}, {\it g}, {\it b})&convert RGB to Octave image\cr |
|
802 \omit\tt saveimage ({\it file}, {\it img}, {\it fmt}, {\it map})\quad\rm |
|
803 save a matrix to {\it file}\span\cr |
|
804 \endsec |
|
805 |
|
806 \altsec Sets; |
|
807 create\_set ({\it a}, {\it b})&create row vector of unique values\cr |
|
808 complement ({\it a}, {\it b})&elements of {\it b} not in {\it a}\cr |
|
809 intersection ({\it a}, {\it b})&intersection of sets {\it a} and {\it b}\cr |
|
810 union ({\it a}, {\it b})&union of sets {\it a} and {\it b}\cr |
|
811 \endsec |
|
812 |
|
813 \altsec Strings; |
|
814 strcmp ({\it s}, {\it t})&compare strings\cr |
|
815 strcat ({\it s}, {\it t}, ...)&concatenate strings\cr |
|
816 \endsec |
|
817 |
|
818 \vfill\eject |
|
819 |
|
820 \altsec C-style Input and Output; |
|
821 fopen ({\it name}, {\it mode})&open file {\it name}\cr |
|
822 fclose ({\it file})&close {\it file}\cr |
|
823 printf ({\it fmt}, ...)&formatted output to {\tt stdout}\cr |
|
824 fprintf ({\it file}, {\it fmt}, ...)&formatted output to {\it file}\cr |
|
825 sprintf ({\it fmt}, ...)&formatted output to string\cr |
|
826 scanf ({\it fmt})&formatted input from {\tt stdin}\cr |
|
827 fscanf ({\it file}, {\it fmt})&formatted input from {\it file}\cr |
|
828 sscanf ({\it str}, {\it fmt})&formatted input from {\it string}\cr |
|
829 fgets ({\it file}, {\it len})&read {\it len\/} characters from {\it file\/}\cr |
|
830 fflush ({\it file})&flush pending output to {\it file}\cr |
|
831 ftell ({\it file})&return file pointer position\cr |
|
832 frewind ({\it file})&move file pointer to beginning\cr |
|
833 freport&print a info for open files\cr |
|
834 fread ({\it file}, {\it size}, {\it prec})&read binary data files\cr |
|
835 fwrite ({\it file}, {\it size}, {\it prec})&write binary data files\cr |
|
836 feof ({\it file})&determine if pointer is at EOF\cr |
|
837 \omit \vbox{\rm\vskip0.75ex |
|
838 A file may be referenced either by name or by the number returned |
|
839 from {\tt fopen}. Three files are preconnected when Octave starts: |
|
840 {\tt stdin}, {\tt stdout}, and {\tt stderr}.\vskip0.75ex}\span\cr |
|
841 \endsec |
|
842 |
|
843 \sec Other Input and Output functions; |
|
844 save {\it file} {\it var} ...&save variables in {\it file}\cr |
|
845 load {\it file}&load variables from {\it file}\cr |
|
846 disp ({\it var})&display value of {\it var} to screen\cr |
|
847 \endsec |
|
848 |
|
849 \sec Miscellaneous Functions; |
|
850 eval ({\it str})&evaluate {\it str} as a command\cr |
|
851 feval ({\it str}, ...)&evaluate function named by {\it str}, |
|
852 passing remaining args to called function\cr\cr |
|
853 error ({\it message})&print message and return to top level\cr\cr |
|
854 clear {\it pattern}&clear variables matching pattern\cr |
|
855 exist ({\it str})&check existence of variable or function\cr |
|
856 who&list current variables\cr |
|
857 \endsec |
|
858 |
|
859 \sec Polynomials; |
|
860 compan ({\it p})&companion matrix\cr |
|
861 conv ({\it a}, {\it b})&convolution\cr |
|
862 deconv ({\it a}, {\it b})&deconvolve two vectors\cr |
|
863 poly ({\it a})&create polynomial from a matrix\cr |
|
864 polyderiv ({\it p})&derivative of polynomial\cr |
|
865 polyreduce ({\it p})&integral of polynomial\cr |
|
866 polyval ({\it p}, {\it x})&value of polynomial at {\it x}\cr |
|
867 polyvalm ({\it p}, {\it x})&value of polynomial at {\it x}\cr |
|
868 roots ({\it p})&polynomial roots\cr |
|
869 residue ({\it a}, {\it b})&partial fraction expansion of |
|
870 ratio {\it a}/{\it b}\cr |
|
871 \endsec |
|
872 |
|
873 \sec Statistics; |
|
874 corrcoef ({\it x}, {\it y})&correlation coefficient\cr |
|
875 cov ({\it x}, {\it y})&covariance\cr |
|
876 mean ({\it a})&mean value\cr |
|
877 median ({\it a})&median value\cr |
|
878 std ({\it a})&standard deviation\cr |
|
879 var ({\it a})&variance\cr |
|
880 \endsec |
|
881 |
|
882 \vfill\eject |
|
883 |
|
884 \sec Basic Plotting; |
|
885 \omit \vbox{\tt |
|
886 gplot \opt{{\it ranges}} {\it expr} \opt{{\it using}} |
|
887 \opt{{\it title}} \opt{{\it style}}\hfill{\rm 2D plotting} |
|
888 \par\vskip \lskip}\span\cr |
|
889 \omit \vbox{\tt |
|
890 gsplot \opt{{\it ranges}} {\it expr} \opt{{\it using}} |
|
891 \opt{{\it title}} \opt{{\it style}}\hfill{\rm 3D plotting} |
|
892 \par\vskip \lskip}\span\cr |
|
893 \quad{\it ranges}&specify data ranges\cr |
|
894 \quad{\it expr}&expression to plot\cr |
|
895 \quad{\it using}&specify columns to plot\cr |
|
896 \quad{\it title}&specify line title for legend\cr |
|
897 \quad{\it style}&specify line style\cr |
|
898 \omit \vbox{\rm\vskip0.85ex |
|
899 If {\it ranges\/} are supplied, they must come before the expression |
|
900 to plot. The {\it using\/}, {\it title\/}, and {\it style\/} |
|
901 options may appear in any order after {\it expr\/}. Multiple |
|
902 expressions may be plotted with a single command by separating them |
|
903 with commas.\vskip1ex}\span\cr |
|
904 set {\it options}&set plotting options\cr |
|
905 show {\it options}&show plotting options\cr |
|
906 replot&redisplay current plot\cr |
|
907 closeplot&close stream to {\tt gnuplot} process\cr |
|
908 purge\_tmp\_files&clean up temporary plotting files\cr |
|
909 automatic\_replot&built-in variable\cr |
|
910 \endsec |
|
911 |
|
912 \sec Other Plotting Functions; |
|
913 plot ({\it args})&2D plot with linear axes\cr |
|
914 semilogx ({\it args})&2D plot with logarithmic x-axis\cr |
|
915 semilogy ({\it args})&2D plot with logarithmic y-axis\cr |
|
916 loglog ({\it args})&2D plot with logarithmic axes\cr |
|
917 bar ({\it args})&plot bar charts\cr |
|
918 stairs ({\it x}, {\it y})&plot stairsteps\cr |
|
919 hist ({\it y}, {\it x})&plot histograms\cr\cr |
|
920 title ({\it string})&set plot title\cr\cr |
|
921 axis ({\it limits})&set axis ranges\cr |
|
922 xlabel ({\it string})&set x-axis label\cr |
|
923 ylabel ({\it string})&set y-axis label\cr |
|
924 grid \opt{on$|$off}&set grid state\cr |
|
925 hold \opt{on$|$off}&set hold state\cr |
|
926 ishold&return 1 if hold is on, 0 otherwise\cr\cr |
|
927 mesh ({\it x}, {\it y}, {\it z})&plot 3D surface\cr |
|
928 meshdom ({\it x}, {\it y})&create mesh coordinate matrices\cr |
|
929 \endsec |
|
930 |
|
931 \vskip 0pt plus 2fill |
|
932 \hrule width \hsize |
|
933 \par\vskip10pt |
|
934 {\smrm\parskip=6pt |
|
935 Edition \refcardedition for Octave Version \octaveversion. Copyright |
|
936 1996, John W. Eaton |
|
937 (jwe@che.utexas.edu). The author assumes no responsibility for any |
|
938 errors on this card. |
|
939 |
|
940 This card may be freely distributed under the terms of the GNU |
|
941 General Public License. |
|
942 |
|
943 \TeX{} Macros for this card by Roland Pesch (pesch@cygnus.com), |
|
944 originally for the GDB reference card |
|
945 |
|
946 Octave itself is free software; you are welcome to distribute copies of |
|
947 it under the terms of the GNU General Public License. There is |
|
948 absolutely no warranty for Octave. |
|
949 } |
|
950 |
|
951 \end |
|
952 |
|
953 % For AUCTeX: |
|
954 % |
|
955 % Local Variables: |
|
956 % mode: tex |
|
957 % TeX-master: t |
|
958 % End: |