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