3
% This file is TeX source for a reference card describing Octave.
5
% Copyright (C) 1996-2013 John W. Eaton
7
% This file is part of Octave.
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.
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
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/>.
23
% Heavily modified by jwe from the source for the gdb reference card,
24
% which was orignally written by Roland Pesch <pesch@cygnus.com>.
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.
31
% TeX markup is a programming language; accordingly this file is source
32
% for a program to generate a reference.
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
43
% To find the configuration places, just search for the string
44
% "User configuration".
46
% -- Andreas Vogel (av@ssw.de)
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.
53
\def\octaveversion{3.0.0}
54
\def\refcardedition{2.0}
60
% Declarations (these must come first)
70
\newdimen\intersecwidth
72
\newcount\columnsperpage
74
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
78
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
80
% There are currently 8 total columns, so some of these options will
81
% not create a single page reference card.
83
% Choose a paper size. Default is US letter size.
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)
87
\def\refcardlettersize{letter} % 3 columns, US letter paper (8.5 x 11in)
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
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
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
117
\ifx\pdfoutput\undefined
119
\pdfpageheight=\totalheight
120
\pdfpagewidth=\totalwidth
123
% Change according to personal taste, not papersize dependent.
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
129
% Uncomment only one of the following definitions for folding guides.
131
% No printed folding guide:
133
%\def\vdecor{\hskip\hmargin plus1fil
134
% \hskip\barwidth plus1fil
135
% \hskip\hmargin plus1fil}
137
% Solid line folding guide:
139
%\def\vdecor{\hskip\hmargin plus1fil%
140
% \vrule width \barwidth%
141
% \hskip\hmargin plus1fil}
143
% For small marks near top and bottom as folding guide:
145
\def\vdecor{\hskip\hmargin plus1fil%
146
\vbox to \vsize{\hbox to \barwidth{\vrule height\barheight width\barwidth}%
148
\hbox to \barwidth{\vrule height\barheight width\barwidth}}%
149
\hskip\hmargin plus1fil}
151
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
153
% END CONFIGURATION %
155
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
157
% values to be computed based on above definitions.
158
% nothing to configure
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
166
% an alternate section format, used in some cases to make text fit better.
168
\newdimen\altitmwid % width of item column in altsec
169
\newdimen\altdfnwid % width of definition column in altsec
171
% Subtract hmargin for left and right sides of paper from full width.
173
% fullhsize = totalwidth - (2 * hmargin)
175
\fullhsize=\totalwidth
178
\advance \fullhsize by -\temp
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.
186
% hsize = (fullhsize - (ncols-1)*barwidth - 2*(ncols-1)*hmargin) / ncols
189
\tmpcnt\columnsperpage
190
\advance \tmpcnt by -1
195
\multiply \temp by \tmpcnt
196
\advance \hsize by -\temp
198
\multiply \tmpcnt by 2
201
\multiply \temp by \tmpcnt
202
\advance \hsize by -\temp
204
\divide \hsize by \columnsperpage
206
% Vertical size is easy -- same amount of space above and below.
208
% vsize = totalheight - (2 * vmargin)
213
\advance \vsize by -\temp
215
% adjust the offsets so the margins are measured *from paper edge*
217
\hoffset=-1in \advance \hoffset by \hmargin
218
\voffset=-1in \advance \voffset by \vmargin
220
% Width of items in a section.
222
% itmwid = (hsize - intersecwidth) * 1/3
223
% dfnwid = (hsize - intersecwidth) * 2/3
228
\advance \temp by -\intersecwidth
232
% width of the corresponding definition
235
\advance \dfnwid by -\itmwid
237
% indentation for sub items, etc.
239
\temp=\hsize \advance\temp by -1em
242
% Width of items in an alt section.
244
\altitmwid=\itmwid \advance \altitmwid by 0.35in
245
\altdfnwid=\dfnwid \advance \altdfnwid by -0.35in
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.
262
\global\advance\colno by 1
264
\global\setbox\holdbox=\columnbox
266
\ifnum\colno=\columnsperpage
267
\shipout\hbox to \fullhsize{\box\holdbox\vdecor\columnbox}
271
\global\setbox\holdbox=\vbox{\hbox{\box\holdbox\vdecor\columnbox}}
275
\def\columnbox{\leftline{\pagebody}}
279
\if R\lcr \null\vfill\eject \fi
294
% We can afford to allow some slop
302
\normalbaselineskip=9pt
307
\footline={\vbox to0pt{\hss}}
309
\def\ctl#1{{\tt C-#1}}
310
\def\opt#1{{\brm[{\rm #1}]}}
311
\def\xtra#1{\noalign{\smallskip{\tt#1}}}
315
\long\def\sec#1;#2\endsec{\vskip \secskip
318
% column 1 (of halign):
320
\vtop{\hsize=\itmwid\tt ##\par\vskip \lskip }\hfil
322
% column 2 (of halign):
327
\hangindent=\intersecwidth
328
\rm ##\par\vskip \lskip}\cr
330
% Tail of \long\def fills in halign body with \sec args:
336
\long\def\widesec#1;#2\endsec{\vskip \secskip
339
% column 1 (of halign):
342
##\par\vskip \lskip }\cr
344
% Tail of \long\def fills in halign body with \sec args:
346
\noalign{{\bbf #1}\vskip 3\lskip}
349
% an alternate section format, used in some cases to make text fit better.
351
\long\def\altsec#1;#2\endsec{\vskip \secskip
354
% column 1 (of halign):
356
\vtop{\hsize=\altitmwid\tt
357
##\par\vskip \lskip}\hfil
359
% column 2 (of halign):
364
\hangindent=\intersecwidth
365
\rm ##\par\vskip \lskip}\cr
367
% Tail of \long\def fills in halign body with \sec args:
369
\noalign{{\bbf #1}\vskip \lskip}
372
% -------------------------------------
373
% The actual text of the reference card
374
% -------------------------------------
376
{\vbbf Octave Quick Reference}\hfil{\smrm Octave Version \octaveversion}\qquad
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 --eval {\it code}&Evaluate {\it code} using Octave\cr
382
octave --help&describe command line options\cr
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
392
help&list all commands and built-in variables\cr
393
help {\it command}&briefly describe {\it command}\cr
394
doc&use Info to browse Octave manual\cr
395
doc {\it command}&search for {\it command} in Octave manual\cr
396
lookfor {\it str}&search for {\it command} based on {\it str}\cr
400
SPC {\rm or} C-v&scroll forward one screenful\cr
401
DEL {\rm or} M-v&scroll backward one screenful\cr
402
C-l&redraw the display\cr
405
\sec Node Selection in Info;
406
n&select the next node\cr
407
p&select the previous node\cr
408
u&select the `up' node\cr
409
t&select the `top' node\cr
410
d&select the directory node\cr
411
<&select the first node in the current file\cr
412
>&select the last node in the current file\cr
413
% ]&move forward through the node structure\cr
414
% [&move backward through the nodes\cr
415
g&reads the name of a node and selects it\cr
416
C-x k&kills the current node\cr
419
\sec Searching in Info;
420
s&search for a string\cr
421
C-s&search forward incrementally\cr
422
C-r&search backward incrementally\cr
423
i&search index \& go to corresponding node\cr
424
,&go to next match from last `i' command\cr
427
\sec Command-Line Cursor Motion;
428
C-b&move back one character\cr
429
C-f&move forward one character\cr
430
C-a&move to the start of the line\cr
431
C-e&move to the end of the line\cr
432
M-f&move forward a word\cr
433
M-b&move backward a word\cr
434
C-l&clear screen, reprinting current line at top\cr
437
\sec Inserting or Changing Text;
438
M-TAB&insert a tab character\cr
439
DEL&delete character to the left of the cursor\cr
440
C-d&delete character under the cursor\cr
441
C-v&add the next character verbatim\cr
442
C-t&transpose characters at the point\cr
443
M-t&transpose words at the point\cr
444
% M-u&uppercase the current word\cr
445
% M-l&lowercase the current word\cr
446
% M-c&capitalize the current word\cr
450
\line{\smrm \opt{ } surround optional arguments
451
\hfill ... show one or more arguments}
452
\vskip0.25\baselineskip
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
463
\sec Command Completion and History;
464
TAB&complete a command or variable name\cr
465
M-?&list possible completions\cr
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
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
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
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
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
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, assuming
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
516
\sec Multi-dimensional Arrays;
517
\omit\vbox{\rm\vskip0.25ex
518
Multi-dimensional arrays may be created with the {\it cat} or
519
{\it reshape} commands from two-dimensional sub-matrices.
520
\vskip0.75ex}\span\cr
521
squeeze ({\it arr})&remove singleton dimensions of the array.\cr
522
ndims ({\it arr})&number of dimensions in the array.\cr
523
permute ({\it arr}, {\it p})&permute the dimensions of an array.\cr
524
ipermute ({\it arr}, {\it p})&array inverse permutation.\cr
530
shiftdim ({\it arr}, {\it s})&rotate the array dimensions.\cr
531
circshift ({\it arr}, {\it s})&rotate the array elements.\cr
534
\sec Sparse Matrices;
535
sparse (...)&create a sparse matrix.\cr
536
speye ({\it n)}&create sparse identity matrix.\cr
537
sprand ({\it n}, {\it m}, {\it d})&sparse rand matrix of density {\it d}.\cr
538
spdiags (...)&sparse generalization of {\it diag}.\cr
539
nnz ({\it s})&No. non-zero elements in sparse matrix.\cr
543
{\it base} : {\it limit}\cr
544
{\it base} : {\it incr} : {\it limit}\cr
545
\omit\hfill\vbox{\hsize=\idnwid\rm\vskip0.75ex
546
Specify a range of values beginning with {\it base\/} with no elements
547
greater than {\it limit}. If it is omitted, the default value of
548
{\it incr\/} is 1. Negative increments are permitted.}\span\cr
551
\sec Strings and Common Escape Sequences;
552
\omit\vbox{\rm\vskip0.5ex
553
A {\it string constant\/} consists of a sequence of characters
554
enclosed in either double-quote or single-quote marks. Strings
555
in double-quotes allow the use of the escape sequences below.
556
\vskip0.75ex}\span\cr
557
\char'134\char'134&a literal backslash\cr
558
\char'134 "&a literal double-quote character\cr
559
\char'134 '&a literal single-quote character\cr
560
\char'134 n&newline, ASCII code 10\cr
561
\char'134 t&horizontal tab, ASCII code 9\cr
564
\sec Index Expressions;
565
{\it var} ({\it idx})&select elements of a vector\cr
566
{\it var} ({\it idx1}, {\it idx2})&select elements of a matrix\cr
568
\quad {\it scalar}&select row (column) corresponding to {\it scalar}\cr
569
\quad {\it vector}&select rows (columns) corresponding to the elements
571
\quad {\it range}&select rows (columns) corresponding to the elements
573
\quad :&select all rows (columns)\cr
576
\sec Global and Persistent Variables;
577
global {\it var1} ...&Declare variables global.\cr
578
global {\it var1} = {\it val}&Declare variable global. Set initial value.\cr
579
persistent {\it var1}&Declare a variable as static to a function.\cr
580
persistent {\it var1} = {\it val}&Declare a variable as static to a
581
function and set its initial value.\cr
582
\omit\hfill\vbox{\rm\vskip0.25ex
583
Global variables may be accessed inside the body of a function
584
without having to be passed in the function parameter list provided
585
they are declared global when used.}\span\cr
588
\sec Selected Built-in Functions;
589
EDITOR&editor to use with {\tt edit\_history}\cr
590
Inf, NaN&IEEE infinity, NaN\cr
592
PAGER&program to use to paginate output\cr
593
ans&last result not explicitly assigned\cr
594
eps&machine precision\cr
597
realmax&maximum representable value\cr
598
realmin&minimum representable value\cr
602
\centerline{\smrm Copyright 1996, 1997, 2007 John W. Eaton\qquad Permissions on back}
605
\sec Assignment Expressions;
606
{\it var} = {\it expr}&assign expression to variable\cr
607
{\it var} ({\it idx}) = {\it expr}&assign expression to indexed variable\cr
608
{\it var} ({\it idx}) = []&delete the indexed elements.\cr
609
{\it var} $\{${\it idx}$\}$ = {\it expr}&assign elements of a cell array.\cr
612
\sec Arithmetic and Increment Operators;
613
{\it x} + {\it y}&addition\cr
614
{\it x} - {\it y}&subtraction\cr
615
{\it x} * {\it y}&matrix multiplication\cr
616
{\it x} .* {\it y}&element by element multiplication\cr
617
{\it x} / {\it y}&right division, conceptually equivalent to
618
{\tt (inverse~(y')~*~x')'}\cr
619
{\it x} ./ {\it y}&element by element right division\cr
620
{\it x} \char'134{} {\it y}&left division, conceptually equivalent to
621
{\tt inverse~(x)~*~y}\cr
622
{\it x} .\char'134{} {\it y}&element by element left division\cr
623
{\it x} \char'136{} {\it y}&power operator\cr
624
{\it x} .\char'136{} {\it y}&element by element power operator\cr
625
- {\it x}&negation\cr
626
+ {\it x}&unary plus (a no-op)\cr
627
{\it x} '&complex conjugate transpose\cr
628
{\it x} .'&transpose\cr
629
return {\it new\/} value\cr
630
{\it x} ++\quad{\rm(}{\it x} --{\rm)}&increment (decrement),
631
return {\it old\/} value\cr
634
\sec Comparison and Boolean Operators;
635
\omit \vbox{\rm\vskip0.75ex
636
These operators work on an element-by-element basis. Both arguments
637
are always evaluated.\vskip0.75ex}\span\cr
638
{\it x} < {\it y}&true if {\it x\/} is less than {\it y}\cr
639
{\it x} <= {\it y}&true if {\it x\/} is less than or equal to {\it y}\cr
640
{\it x} == {\it y}&true if {\it x\/} is equal to {\it y}\cr
641
{\it x} >= {\it y}&true if {\it x\/} is greater than or equal to {\it y}\cr
642
{\it x} > {\it y}&true if {\it x\/} is greater than {\it y}\cr
643
{\it x} != {\it y}&true if {\it x\/} is not equal to {\it y}\cr
644
{\it x} \& {\it y}&true if both {\it x\/} and {\it y\/} are true\cr
645
{\it x} | {\it y}&true if at least one of {\it x\/} or {\it y\/} is true\cr
646
! {\it bool}&true if {\it bool\/} is false\cr
649
\sec Short-circuit Boolean Operators;
650
\omit \vbox{\rm\vskip0.75ex
651
Operators evaluate left-to-right. Operands are only evaluated if
652
necessary, stopping once overall truth value can be determined.
653
Operands are converted to scalars using the {\tt all}
654
function.\vskip0.75ex}\span\cr
655
{\it x} \&\& {\it y}&true if both {\it x\/} and {\it y\/} are true\cr
656
{\it x} || {\it y}&true if at least one of {\it x\/} or {\it y\/} is true\cr
659
\sec Operator Precedence;
660
\omit \vbox{\rm\vskip0.5ex
661
Table of Octave operators, in order of increasing
662
precedence.\vskip0.75ex}\span\cr
663
;\ \ ,&statement separators\cr
664
=&assignment, groups left to right\cr
665
||\ \ \&\&&logical ``or'' and ``and''\cr
666
|\ \ \&&element-wise ``or'' and ``and''\cr
667
< <= == >= > !=&relational operators\cr
669
+\ \ -&addition and subtraction\cr
670
* / \char'134\ \ .*\ \ ./\ \ .\char'134&multiplication and division\cr
672
+\ \ -\ \ ++\ \ --\ \ !&unary minus, increment, logical ``not''\cr
673
\char'136\ \ .\char'136&exponentiation\cr
678
\sec Paths and Packages;
679
path&display the current Octave function path.\cr
680
pathdef&display the default path.\cr
681
addpath ({\it dir})&add a directory to the path.\cr
682
EXEC\_PATH&manipulate the Octave executable path.\cr
683
pkg list&display installed packages.\cr
684
pkg load {\it pack}&Load an installed package.\cr
687
\sec Cells and Structures;
688
{\it{var}}.{\it{field}} = ...&set a field of a structure.\cr
689
{\it{var}}$\{${\it{idx}}$\}$ = ...&set an element of a cell array.\cr
690
cellfun ({\it f}, {\it c})&apply a function to elements of cell array.\cr
691
fieldnames ({\it s})&returns the fields of a structure.\cr
695
for {\it identifier} = {\it expr} {\it stmt-list} endfor\cr
696
\hfill\vbox{\hsize=\idnwid\rm\vskip0.25ex
697
Execute {\it stmt-list} once for each column of {\it expr}. The
698
variable {\it identifier} is set to the value of the current column
699
during each iteration.}\cr\cr
700
while ({\it condition}) {\it stmt-list} endwhile\cr
701
\hfill\vbox{\hsize=\idnwid\rm\vskip0.25ex
702
Execute {\it stmt-list} while {\it condition} is true.}\cr\cr
703
\hbox{\vtop{\hsize=\itmwid\tt break}
704
\vtop{\hsize=\dfnwid\rm exit innermost loop}}\cr
705
\hbox{\vtop{\hsize=\itmwid\tt continue}
706
\vtop{\hsize=\dfnwid\rm go to beginning of innermost loop}}\cr
707
\hbox{\vtop{\hsize=\itmwid\tt return}
708
\vtop{\hsize=\dfnwid\rm return to calling function}}\cr\cr
709
if ({\it condition}) {\it if-body} \opt{{\tt else} {\it else-body}} endif\cr
710
\hfill\vbox{\hsize=\idnwid\rm\vskip0.25ex
711
Execute {\it if-body} if {\it condition} is true, otherwise execute
713
if ({\it condition}) {\it if-body} \opt{{\tt elseif} ({\it condition})
714
{\it elseif-body}} endif\cr
715
\hfill\vbox{\hsize=\idnwid\rm\vskip0.25ex
716
Execute {\it if-body} if {\it condition} is true, otherwise execute
717
the {\it elseif-body} corresponding to the first {\tt elseif}
718
condition that is true, otherwise execute {\it else-body}.}\cr
719
\hfill\vbox{\hsize=\idnwid\rm\vskip0.25ex
720
Any number of {\tt elseif} clauses may appear in an {\tt if}
722
unwind\_protect {\it body} unwind\_protect\_cleanup {\it cleanup} end\cr
723
\hfill\vbox{\hsize=\idnwid\rm\vskip0.25ex
724
Execute {\it body}. Execute {\it cleanup} no matter how control
725
exits {\it body}.}\cr
726
try {\it body} catch {\it cleanup} end\cr
727
\hfill\vbox{\hsize=\idnwid\rm\vskip0.25ex
728
Execute {\it body}. Execute {\it cleanup} if {\it body} fails.}\cr
732
strcmp ({\it s}, {\it t})&compare strings\cr
733
strcat ({\it s}, {\it t}, ...)&concatenate strings\cr
734
regexp ({\it str}, {\it pat})&strings matching regular expression\cr
735
regexprep ({\it str}, {\it pat}, {\it rep})&Match and replace sub-strings\cr
738
\widesec Defining Functions;
739
function \opt{{\it ret-list}} {\it function-name}
740
\opt{\hskip0.2em({\it arg-list})\hskip0.2em}\cr
741
\quad{\it function-body}\cr
743
{\rm {\it ret-list\/} may be a single identifier or a comma-separated
744
list of identifiers delimited by square-brackets.\vskip0.75ex}\cr
745
{\rm {\it arg-list\/} is a comma-separated list of identifiers and may
751
\sec Function Handles;
752
@{\it{func}}& Define a function handle to {\it func}.\cr
753
@({\it var1}, ...) {\it expr}&Define an anonymous function handle.\cr
754
str2func ({\it str})&Create a function handle from a string.\cr
755
functions ({\it handle})&Return information about a function handle.\cr
756
func2str ({\it handle})&Return a string representation of a
758
{\it handle} ({\it arg1}, ...)&Evaluate a function handle.\cr
759
feval ({\it func}, {\it arg1}, ...)&Evaluate a function handle or
760
string, passing remaining args to {\it func}\cr
761
\omit\vbox{\rm\vskip0.25ex
762
Anonymous function handles take a copy of the variables in the
763
current workspace.\vskip0.75ex}\span\cr
766
\sec Miscellaneous Functions;
767
eval ({\it str})&evaluate {\it str} as a command\cr
768
error ({\it message})&print message and return to top level\cr
769
warning ({\it message})&print a warning message\cr
770
clear {\it pattern}&clear variables matching pattern\cr
771
exist ({\it str})&check existence of variable or function\cr
772
who, whos&list current variables\cr
773
whos {\it var}&details of the variable {\it var}\cr
776
\sec Basic Matrix Manipulations;
777
rows ({\it a})&return number of rows of {\it a}\cr
778
columns ({\it a})&return number of columns of {\it a}\cr
779
all ({\it a})&check if all elements of {\it a\/} nonzero\cr
780
any ({\it a})&check if any elements of {\it a\/} nonzero\cr
784
find ({\it a})&return indices of nonzero elements\cr
785
sort ({\it a})&order elements in each column of {\it a}\cr
786
sum ({\it a})&sum elements in columns of {\it a}\cr
787
prod ({\it a})&product of elements in columns of {\it a}\cr
788
min ({\it args})&find minimum values\cr
789
max ({\it args})&find maximum values\cr
790
rem ({\it x}, {\it y})&find remainder of {\it x}/{\it y}\cr
791
reshape ({\it a}, {\it m}, {\it n})&reformat {\it a} to be {\it m} by
793
diag ({\it v}, {\it k})&create diagonal matrices\cr
794
linspace ({\it b}, {\it l}, {\it n})&create vector of linearly-spaced
796
logspace ({\it b}, {\it l}, {\it n})&create vector of log-spaced
798
eye ({\it n}, {\it m})&create {\it n\/} by {\it m\/} identity matrix\cr
799
ones ({\it n}, {\it m})&create {\it n\/} by {\it m\/} matrix of ones\cr
800
zeros ({\it n}, {\it m})&create {\it n\/} by {\it m\/} matrix of zeros\cr
801
rand ({\it n}, {\it m})&create {\it n\/} by {\it m\/} matrix of random
805
% sin ({\it a}) cos({\it a}) tan({\it a})&trigonometric functions\cr
806
% asin ({\it a}) acos({\it a}) atan({\it a})&inverse trigonometric functions\cr
807
% sinh ({\it a}) cosh({\it a}) tanh({\it a})&hyperbolic trig functions\cr
808
% asinh ({\it a}) acosh({\it a}) atanh({\it a})&inverse hyperbolic trig
812
chol ({\it a})&Cholesky factorization\cr
813
det ({\it a})&compute the determinant of a matrix\cr
814
eig ({\it a})&eigenvalues and eigenvectors\cr
815
expm ({\it a})&compute the exponential of a matrix\cr
816
hess ({\it a})&compute Hessenberg decomposition\cr
817
inverse ({\it a})&invert a square matrix\cr
818
norm ({\it a}, {\it p})&compute the {\it p}-norm of a matrix\cr
819
pinv ({\it a})&compute pseudoinverse of {\it a}\cr
820
qr ({\it a})&compute the QR factorization of a matrix\cr
821
rank ({\it a})&matrix rank\cr
822
sprank ({\it a})&structural matrix rank\cr
823
schur ({\it a})&Schur decomposition of a matrix\cr
824
svd ({\it a})&singular value decomposition\cr
825
syl ({\it a}, {\it b}, {\it c})&solve the Sylvester equation\cr
830
\sec Equations, ODEs, DAEs, Quadrature;
831
*fsolve&solve nonlinear algebraic equations\cr
832
*lsode&integrate nonlinear ODEs\cr
833
*dassl&integrate nonlinear DAEs\cr
834
*quad&integrate nonlinear functions\cr
835
perror ({\it nm}, {\it code})&for functions that return numeric
836
codes, print error message for named function and given error
839
{\tt *} See the on-line or printed manual for the complete list of
840
arguments for these functions.}\span\cr
844
% create\_set ({\it a}, {\it b})&create row vector of unique values\cr
845
% complement ({\it a}, {\it b})&elements of {\it b} not in {\it a}\cr
846
% intersection ({\it a}, {\it b})&intersection of sets {\it a} and {\it b}\cr
847
% union ({\it a}, {\it b})&union of sets {\it a} and {\it b}\cr
850
\sec Signal Processing;
851
fft ({\it a})&Fast Fourier Transform using FFTW\cr
852
ifft ({\it a})&inverse FFT using FFTW\cr
853
freqz ({\it args})&FIR filter frequency response\cr
854
filter ({\it a}, {\it b}, {\it x})&filter by transfer function\cr
855
conv ({\it a}, {\it b})&convolve two vectors\cr
856
hamming ({\it n})&return Hamming window coefficients\cr
857
hanning ({\it n})&return Hanning window coefficients\cr
860
\altsec Image Processing;
861
colormap ({\it map})&set the current colormap\cr
862
gray2ind ({\it i}, {\it n})&convert gray scale to Octave image\cr
863
image ({\it img}, {\it zoom})&display an Octave image matrix\cr
864
imagesc ({\it img}, {\it zoom})&display scaled matrix as image\cr
865
imread ({\it file})&load an image file\cr
866
imshow ({\it img}, {\it map})&display Octave image\cr
867
imshow ({\it i}, {\it n})&display gray scale image\cr
868
imshow ({\it r}, {\it g}, {\it b})&display RGB image\cr
869
imwrite ({\it img}, {\it file})&write images in various file formats\cr
870
ind2gray ({\it img}, {\it map})&convert Octave image to gray scale\cr
871
ind2rgb ({\it img}, {\it map})&convert indexed image to RGB\cr
872
rgb2ind ({\it r}, {\it g}, {\it b})&convert RGB to Octave image\cr
873
save a matrix to {\it file}\span\cr
876
\altsec C-style Input and Output;
877
fopen ({\it name}, {\it mode})&open file {\it name}\cr
878
fclose ({\it file})&close {\it file}\cr
879
printf ({\it fmt}, ...)&formatted output to {\tt stdout}\cr
880
fprintf ({\it file}, {\it fmt}, ...)&formatted output to {\it file}\cr
881
sprintf ({\it fmt}, ...)&formatted output to string\cr
882
scanf ({\it fmt})&formatted input from {\tt stdin}\cr
883
fscanf ({\it file}, {\it fmt})&formatted input from {\it file}\cr
884
sscanf ({\it str}, {\it fmt})&formatted input from {\it string}\cr
885
fgets ({\it file}, {\it len})&read {\it len\/} characters from {\it file\/}\cr
886
fflush ({\it file})&flush pending output to {\it file}\cr
887
ftell ({\it file})&return file pointer position\cr
888
frewind ({\it file})&move file pointer to beginning\cr
889
freport&print a info for open files\cr
890
fread ({\it file}, {\it size}, {\it prec})&read binary data files\cr
891
fwrite ({\it file}, {\it size}, {\it prec})&write binary data files\cr
892
feof ({\it file})&determine if pointer is at EOF\cr
893
\omit \vbox{\rm\vskip0.75ex
894
A file may be referenced either by name or by the number returned
895
from {\tt fopen}. Three files are preconnected when Octave starts:
896
{\tt stdin}, {\tt stdout}, and {\tt stderr}.\vskip0.75ex}\span\cr
899
\sec Other Input and Output functions;
900
save {\it file} {\it var} ...&save variables in {\it file}\cr
901
load {\it file}&load variables from {\it file}\cr
902
disp ({\it var})&display value of {\it var} to screen\cr
908
compan ({\it p})&companion matrix\cr
909
conv ({\it a}, {\it b})&convolution\cr
910
deconv ({\it a}, {\it b})&deconvolve two vectors\cr
911
poly ({\it a})&create polynomial from a matrix\cr
912
polyderiv ({\it p})&derivative of polynomial\cr
913
polyreduce ({\it p})&integral of polynomial\cr
914
polyval ({\it p}, {\it x})&value of polynomial at {\it x}\cr
915
polyvalm ({\it p}, {\it x})&value of polynomial at {\it x}\cr
916
roots ({\it p})&polynomial roots\cr
917
residue ({\it a}, {\it b})&partial fraction expansion of
918
ratio {\it a}/{\it b}\cr
922
corrcoef ({\it x}, {\it y})&correlation coefficient\cr
923
cov ({\it x}, {\it y})&covariance\cr
924
mean ({\it a})&mean value\cr
925
median ({\it a})&median value\cr
926
std ({\it a})&standard deviation\cr
927
var ({\it a})&variance\cr
930
\sec Plotting Functions;
931
plot ({\it args})&2D plot with linear axes\cr
932
plot3 ({\it args})&3D plot with linear axes\cr
933
line ({\it args})&2D or 3D line\cr
934
patch ({\it args})&2D patch\cr
935
semilogx ({\it args})&2D plot with logarithmic x-axis\cr
936
semilogy ({\it args})&2D plot with logarithmic y-axis\cr
937
loglog ({\it args})&2D plot with logarithmic axes\cr
938
bar ({\it args})&plot bar charts\cr
939
stairs ({\it x}, {\it y})&plot stairsteps\cr
940
stem ({\it x}, {\it y})&plot a stem graph\cr
941
hist ({\it y}, {\it x})&plot histograms\cr
942
contour ({\it x}, {\it y}, {\it z})&contour plot\cr
943
title ({\it string})&set plot title\cr
944
axis ({\it limits})&set axis ranges\cr
945
xlabel ({\it string})&set x-axis label\cr
946
ylabel ({\it string})&set y-axis label\cr
947
zlabel ({\it string})&set z-axis label\cr
948
text ({\it x}, {\it y}, {\it str})&add text to a plot\cr
949
legend ({\it string})&set label in plot key\cr
950
grid \opt{on$|$off}&set grid state\cr
951
hold \opt{on$|$off}&set hold state\cr
952
ishold&return 1 if hold is on, 0 otherwise\cr
953
mesh ({\it x}, {\it y}, {\it z})&plot 3D surface\cr
954
meshgrid ({\it x}, {\it y})&create mesh coordinate matrices\cr
957
\vskip 0pt plus 2fill
961
Edition \refcardedition\ for Octave Version \octaveversion. Copyright
962
1996, 2007, John W. Eaton
963
(jwe@octave.org). The author assumes no responsibility for any
966
This card may be freely distributed under the terms of the GNU
967
General Public License.
969
\TeX{} Macros for this card by Roland Pesch (pesch@cygnus.com),
970
originally for the GDB reference card
972
Octave itself is free software; you are welcome to distribute copies of
973
it under the terms of the GNU General Public License. There is
974
absolutely no warranty for Octave.