~gabriel1984sibiu/octave/octave

« back to all changes in this revision

Viewing changes to doc/refcard/refcard.tex

  • Committer: Grevutiu Gabriel
  • Date: 2014-01-02 13:05:54 UTC
  • Revision ID: gabriel1984sibiu@gmail.com-20140102130554-3r7ivdjln1ni6kcg
New version (3.8.0) from upstream.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
% refcard.tex
 
2
%
 
3
% This file is TeX source for a reference card describing Octave.
 
4
%
 
5
% Copyright (C) 1996-2013 John W. Eaton
 
6
%
 
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.
 
13
%
 
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.
 
18
%
 
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/>.
 
22
%
 
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
%
 
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{3.0.0}
 
54
\def\refcardedition{2.0}
 
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)
 
87
\def\refcardlettersize{letter} % 3 columns, US letter paper (8.5 x 11in)
 
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
 
 
117
\ifx\pdfoutput\undefined
 
118
\else
 
119
  \pdfpageheight=\totalheight
 
120
  \pdfpagewidth=\totalwidth
 
121
\fi
 
122
 
 
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 --eval {\it code}&Evaluate {\it code} using Octave\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
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
 
397
\endsec
 
398
 
 
399
\sec Motion in Info;
 
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
 
403
\endsec
 
404
 
 
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
 
417
\endsec
 
418
 
 
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
 
425
\endsec
 
426
 
 
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
 
435
\endsec
 
436
 
 
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
 
447
\endsec
 
448
 
 
449
\vfill
 
450
\line{\smrm \opt{ } surround optional arguments
 
451
  \hfill ... show one or more arguments}
 
452
\vskip0.25\baselineskip
 
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, 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
 
514
\endsec
 
515
 
 
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
 
525
\endsec
 
526
 
 
527
\vfill\eject
 
528
 
 
529
\sec ;
 
530
shiftdim ({\it arr}, {\it s})&rotate the array dimensions.\cr
 
531
circshift ({\it arr}, {\it s})&rotate the array elements.\cr
 
532
\endsec
 
533
 
 
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
 
540
\endsec
 
541
 
 
542
\sec Ranges;
 
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
 
549
\endsec
 
550
 
 
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
 
562
\endsec
 
563
 
 
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
 
567
 
 
568
\quad {\it scalar}&select row (column) corresponding to {\it scalar}\cr
 
569
\quad {\it vector}&select rows (columns) corresponding to the elements
 
570
  of {\it vector}\cr
 
571
\quad {\it range}&select rows (columns) corresponding to the elements
 
572
  of {\it range}\cr
 
573
\quad :&select all rows (columns)\cr
 
574
\endsec
 
575
 
 
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
 
586
\endsec
 
587
 
 
588
\sec Selected Built-in Functions;
 
589
EDITOR&editor to use with {\tt edit\_history}\cr
 
590
Inf, NaN&IEEE infinity, NaN\cr
 
591
NA&Missing value\cr
 
592
PAGER&program to use to paginate output\cr
 
593
ans&last result not explicitly assigned\cr
 
594
eps&machine precision\cr
 
595
pi&$\pi$\cr
 
596
1i&$\sqrt{-1}$\cr
 
597
realmax&maximum representable value\cr
 
598
realmin&minimum representable value\cr
 
599
\endsec
 
600
 
 
601
\vfill
 
602
\centerline{\smrm Copyright 1996, 1997, 2007 John W. Eaton\qquad Permissions on back}
 
603
\eject
 
604
 
 
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
 
610
\endsec
 
611
 
 
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
 
632
\endsec
 
633
 
 
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
 
647
\endsec
 
648
 
 
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
 
657
\endsec
 
658
 
 
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
 
668
:&colon\cr
 
669
+\ \ -&addition and subtraction\cr
 
670
* / \char'134\ \ .*\ \ ./\ \ .\char'134&multiplication and division\cr
 
671
'\ \ .'&transpose\cr
 
672
+\ \ -\ \ ++\ \ --\ \ !&unary minus, increment, logical ``not''\cr
 
673
\char'136\ \ .\char'136&exponentiation\cr
 
674
\endsec
 
675
 
 
676
\vfill\eject
 
677
 
 
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
 
685
\endsec
 
686
 
 
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
 
692
\endsec
 
693
 
 
694
\widesec Statements;
 
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
 
712
  {\it else-body}.}\cr
 
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}
 
721
  statement.}\cr\cr
 
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
 
729
\endsec
 
730
 
 
731
\altsec Strings;
 
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
 
736
\endsec
 
737
 
 
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
 
742
endfunction\cr\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
 
746
  be empty.}\cr
 
747
\endsec
 
748
 
 
749
\vfill\eject
 
750
 
 
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
 
757
function handle.\cr
 
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
 
764
\endsec
 
765
 
 
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
 
774
\endsec
 
775
 
 
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
 
781
\endsec
 
782
 
 
783
\sec ;
 
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
 
792
  {\it n}\cr
 
793
diag ({\it v}, {\it k})&create diagonal matrices\cr
 
794
linspace ({\it b}, {\it l}, {\it n})&create vector of linearly-spaced
 
795
  elements\cr
 
796
logspace ({\it b}, {\it l}, {\it n})&create vector of log-spaced
 
797
  elements\cr
 
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
 
802
  values\cr 
 
803
\endsec
 
804
 
 
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
 
809
% functions\cr\cr 
 
810
 
 
811
\sec Linear Algebra;
 
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
 
826
\endsec
 
827
 
 
828
\vfill\eject
 
829
 
 
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
 
837
  code\cr\cr
 
838
\omit \vbox{\rm
 
839
  {\tt *} See the on-line or printed manual for the complete list of
 
840
  arguments for these functions.}\span\cr
 
841
\endsec
 
842
 
 
843
% \altsec Sets;
 
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
 
848
% \endsec
 
849
 
 
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
 
858
\endsec
 
859
 
 
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
 
874
\endsec
 
875
 
 
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
 
897
\endsec
 
898
 
 
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
 
903
\endsec
 
904
 
 
905
\vfill\eject
 
906
 
 
907
\sec Polynomials;
 
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
 
919
\endsec
 
920
 
 
921
\sec Statistics;
 
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
 
928
\endsec
 
929
 
 
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
 
955
\endsec
 
956
 
 
957
\vskip 0pt plus 2fill
 
958
\hrule width \hsize
 
959
\par\vskip10pt
 
960
{\smrm\parskip=6pt
 
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
 
964
errors on this card.
 
965
 
 
966
This card may be freely distributed under the terms of the GNU
 
967
General Public License.
 
968
 
 
969
\TeX{} Macros for this card by Roland Pesch (pesch@cygnus.com),
 
970
originally for the GDB reference card
 
971
 
 
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.
 
975
}
 
976
 
 
977
\end
 
978
 
 
979
% For AUCTeX:
 
980
%
 
981
% Local Variables: 
 
982
% mode: tex
 
983
% TeX-master: t
 
984
% End: