view doc/refcard/refcard.tex @ 19630:0e1f5a750d00

maint: Periodic merge of gui-release to default.
author John W. Eaton <jwe@octave.org>
date Tue, 20 Jan 2015 10:24:46 -0500
parents 9ac2357f19bc 446c46af4b42
children 4197fc428c7d
line wrap: on
line source

% refcard.tex
%
% This file is TeX source for a reference card describing Octave.
%
% Copyright (C) 1996-2013 John W. Eaton
%
% This file is part of Octave.
%
% Octave is free software; you can redistribute it and/or modify it
% under the terms of the GNU General Public License as published by the
% Free Software Foundation; either version 3 of the License, or (at your
% option) any later version.
%
% Octave is distributed in the hope that it will be useful, but WITHOUT
% ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
% FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
% for more details.
%
% You should have received a copy of the GNU General Public License
% along with Octave; see the file COPYING.  If not, see
% <http://www.gnu.org/licenses/>.
%
% Heavily modified by jwe from the source for the gdb reference card,
% which was orignally written by Roland Pesch <pesch@cygnus.com>.
%
%   Copyright (C) 1991, 1992 Free Software Foundation, Inc.
%   Permission is granted to make and distribute verbatim copies of
%   this reference provided the copyright notices and permission notices
%   are preserved on all copies.
%
% TeX markup is a programming language; accordingly this file is source
% for a program to generate a reference.
%
% You only have to set the total width and height of the paper, the
% horizontal and vertical margin space measured from *paper edge*
% and the interline and interspec spacing.
% In order to support a new papersize, you have to fiddle with the
% latter four dimensions. Just try out a few values.
% All other values will be computed at process time so it should be
% quite easy to support different paper sizes - only four values to
% guess :-)
%
% To find the configuration places, just search for the string
% "User configuration".
%
%   -- Andreas Vogel (av@ssw.de)
%
% NOTE ON INTENTIONAL OMISSIONS: This reference card includes many
% Octave commands, but due to space constraints there are some things
% I chose to omit.  In general, not all synonyms for commands are
% covered, nor all variations of a command.

\def\octaveversion{3.0.0}
\def\refcardedition{2.0}

% ------------------
% multicolumn format
% ------------------

% Declarations (these must come first)

\newdimen\totalwidth
\newdimen\totalheight
\newdimen\hmargin
\newdimen\vmargin
\newdimen\secskip
\newdimen\lskip
\newdimen\barwidth
\newdimen\barheight
\newdimen\intersecwidth

\newcount\columnsperpage

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                                                                     %
% CONFIGURATION                                                       %
%                                                                     %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% There are currently 8 total columns, so some of these options will
% not create a single page reference card.

% Choose a paper size.  Default is US letter size.

\def\refcardafoursize{a4}      % 3 columns, A4 paper (1 in = 254 mm)
\def\refcardlegalsize{legal}   % 4 columns, US legal paper (8.5 x 14in)
\def\refcardlettersize{letter} % 3 columns, US letter paper (8.5 x 11in)

\ifx\refcardsize\refcardafoursize
  \columnsperpage=3     % total number of columns to typeset
  \totalwidth=297mm     % total width of paper
  \totalheight=210mm    % total height of paper
  \hmargin=9mm          % horizontal margin width
  \vmargin=7mm          % vertical margin width
  \secskip=3mm          % space between refcard secs
  \lskip=0.4mm          % extra skip between \sec entries
\else
  \ifx\refcardsize\refcardlegalsize
    \columnsperpage=4   % total number of columns to typeset
    \totalwidth=14in    % total width of paper
    \totalheight=8.5in  % total height of paper
    \hmargin=0.20in     % horizontal margin width
    \vmargin=0.25in     % vertical margin width
    \secskip=0.75pc     % space between refcard secs
    \lskip=2pt          % extra skip between \sec entries
  \else
    \columnsperpage=3   % total number of columns to typeset
    \totalwidth=11in    % total width of paper
    \totalheight=8.5in  % total height of paper
    \hmargin=0.25in     % horizontal margin width
    \vmargin=0.25in     % vertical margin width
    \secskip=0.75pc     % space between refcard secs
    \lskip=2pt          % extra skip between \sec entries
  \fi
\fi

\ifx\pdfoutput\undefined
\else
  \pdfpageheight=\totalheight
  \pdfpagewidth=\totalwidth
\fi

% Change according to personal taste, not papersize dependent.

\barwidth=.1pt       % width of the cropmark bar
\barheight=2pt       % height of the cropmark bar
\intersecwidth=0.5em % width between \itmwid and \dfnwid

% Uncomment only one of the following definitions for folding guides.

% No printed folding guide:

%\def\vdecor{\hskip\hmargin plus1fil
%  \hskip\barwidth plus1fil
%  \hskip\hmargin plus1fil}

% Solid line folding guide:

%\def\vdecor{\hskip\hmargin plus1fil%
%  \vrule width \barwidth%
%  \hskip\hmargin plus1fil}

% For small marks near top and bottom as folding guide:

\def\vdecor{\hskip\hmargin plus1fil%
  \vbox to \vsize{\hbox to \barwidth{\vrule height\barheight width\barwidth}%
  \vfill
  \hbox to \barwidth{\vrule height\barheight width\barwidth}}%
  \hskip\hmargin plus1fil}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                                                                      %
% END CONFIGURATION                                                    %
%                                                                      %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% values to be computed based on above definitions.
% nothing to configure

\newdimen\fullhsize          % width of area without margins
\newdimen\itmwid             % width of item column
\newdimen\dfnwid             % width of definition column
\newdimen\idnwid             % width of indented text
\newdimen\temp               % only for temporary use

% an alternate section format, used in some cases to make text fit better.

\newdimen\altitmwid        % width of item column in altsec
\newdimen\altdfnwid        % width of definition column in altsec

% Subtract hmargin for left and right sides of paper from full width.
%
%   fullhsize = totalwidth - (2 * hmargin)

\fullhsize=\totalwidth
\temp=\hmargin
\multiply \temp by 2
\advance \fullhsize by -\temp

% intercolumn space is composed of hmargin barwidth hmargin so that we
% get the same amount of space on either side of the (optional) rule
% between columns.  For N columns, we need to subtract this amount of
% space N-1 times.  Divide by the number of columns to get the final
% value of \hsize that we use to typeset columns.

% hsize = (fullhsize - (ncols-1)*barwidth - 2*(ncols-1)*hmargin) / ncols

\newcount\tmpcnt
\tmpcnt\columnsperpage
\advance \tmpcnt by -1

\hsize=\fullhsize

\temp=\barwidth
\multiply \temp by \tmpcnt
\advance \hsize by -\temp

\multiply \tmpcnt by 2

\temp=\hmargin
\multiply \temp by \tmpcnt
\advance \hsize by -\temp

\divide \hsize by \columnsperpage

% Vertical size is easy -- same amount of space above and below.
%
%   vsize = totalheight - (2 * vmargin)

\vsize=\totalheight
\temp=\vmargin
\multiply \temp by 2
\advance \vsize by -\temp

% adjust the offsets so the margins are measured *from paper edge*

\hoffset=-1in \advance \hoffset by \hmargin
\voffset=-1in \advance \voffset by \vmargin

% Width of items in a section.

% itmwid = (hsize - intersecwidth) * 1/3
% dfnwid = (hsize - intersecwidth) * 2/3

% width of the item

\temp=\hsize
\advance \temp by -\intersecwidth
\divide \temp by 3
\itmwid=\temp

% width of the corresponding definition

\dfnwid=\hsize
\advance \dfnwid by -\itmwid

% indentation for sub items, etc.

\temp=\hsize \advance\temp by -1em
\idnwid=\temp

% Width of items in an alt section.

\altitmwid=\itmwid \advance \altitmwid by 0.35in
\altdfnwid=\dfnwid \advance \altdfnwid by -0.35in

% Output macros.
%
% Strategy:
%
%   * set each column in a box
%   * append new columns in a global `holding' box, inserting
%     intercolumn decorations as necessary.
%   * when we fill a page, dump the saved box and the latest column,
%     separated by the intercolumn decoration.

\newbox\holdbox
\newcount\colno
\colno=0

\output={\relax
  \global\advance\colno by 1
  \ifnum\colno=1
    \global\setbox\holdbox=\columnbox
  \else
    \ifnum\colno=\columnsperpage
      \shipout\hbox to \fullhsize{\box\holdbox\vdecor\columnbox}
      \advancepageno
      \global\colno=0
    \else
      \global\setbox\holdbox=\vbox{\hbox{\box\holdbox\vdecor\columnbox}}
    \fi
  \fi}

\def\columnbox{\leftline{\pagebody}}

\def\bye{\par\vfill
  \supereject
  \if R\lcr \null\vfill\eject \fi
  \end}

% -----
% Fonts
% -----

\font\bbf=cmbx10
\font\vbbf=cmbx12
\font\smrm=cmr6
\font\brm=cmr10
\font\rm=cmr7
\font\it=cmti7
\font\tt=cmtt8

% We can afford to allow some slop

\hfuzz=1pt
\vfuzz=1pt
\hyphenpenalty=5000
\tolerance=2000
\raggedright
\raggedbottom
\normalbaselineskip=9pt
\baselineskip=9pt

\parindent=0pt
\parskip=0pt
\footline={\vbox to0pt{\hss}}

\def\ctl#1{{\tt C-#1}}
\def\opt#1{{\brm[{\rm #1}]}}
\def\xtra#1{\noalign{\smallskip{\tt#1}}}

% A normal section

\long\def\sec#1;#2\endsec{\vskip \secskip
  \halign{%
%
% column 1 (of halign):
%
    \vtop{\hsize=\itmwid\tt ##\par\vskip \lskip }\hfil
%
% column 2 (of halign):
%
    &\vtop{%
      \hsize=\dfnwid
      \hangafter=1
      \hangindent=\intersecwidth
      \rm ##\par\vskip \lskip}\cr
%
% Tail of \long\def fills in halign body with \sec args:
%
    \noalign{{\bbf #1}%
      \vskip \lskip}
    #2}}

\long\def\widesec#1;#2\endsec{\vskip \secskip
  \halign{%
%
% column 1 (of halign):
%
    \vbox{\tt
      ##\par\vskip \lskip }\cr
%
% Tail of \long\def fills in halign body with \sec args:
%
      \noalign{{\bbf #1}\vskip 3\lskip}
    #2}}

% an alternate section format, used in some cases to make text fit better.

\long\def\altsec#1;#2\endsec{\vskip \secskip
  \halign{%
%
% column 1 (of halign):
%
    \vtop{\hsize=\altitmwid\tt
      ##\par\vskip \lskip}\hfil
%
% column 2 (of halign):
%
    &\vtop{%
      \hsize=\altdfnwid
      \hangafter=1
      \hangindent=\intersecwidth
      \rm ##\par\vskip \lskip}\cr
%
% Tail of \long\def fills in halign body with \sec args:
%
    \noalign{{\bbf #1}\vskip \lskip}
    #2}}

% -------------------------------------
% The actual text of the reference card
% -------------------------------------

{\vbbf Octave Quick Reference}\hfil{\smrm Octave Version \octaveversion}\qquad

\sec Starting Octave;
octave&start interactive Octave session\cr
octave {\it file}&run Octave on commands in {\it file}\cr
octave --eval {\it code}&Evaluate {\it code} using Octave\cr
octave --help&describe command line options\cr
\endsec

\sec Stopping Octave;
quit {\rm or} exit&exit Octave\cr
INTERRUPT&({\it e.g.} \ctl{c}) terminate current command and return to
  top-level prompt\cr
\endsec

\sec Getting Help;
help&list all commands and built-in variables\cr
help {\it command}&briefly describe {\it command}\cr
doc&use Info to browse Octave manual\cr
doc {\it command}&search for {\it command} in Octave manual\cr
lookfor {\it str}&search for {\it command} based on {\it str}\cr
\endsec

\sec Motion in Info;
SPC {\rm or} C-v&scroll forward one screenful\cr
DEL {\rm or} M-v&scroll backward one screenful\cr
C-l&redraw the display\cr
\endsec

\sec Node Selection in Info;
n&select the next node\cr
p&select the previous node\cr
u&select the `up' node\cr
t&select the `top' node\cr
d&select the directory node\cr
<&select the first node in the current file\cr
>&select the last node in the current file\cr
% ]&move forward through the node structure\cr
% [&move backward through the nodes\cr
g&reads the name of a node and selects it\cr
C-x k&kills the current node\cr
\endsec

\sec Searching in Info;
s&search for a string\cr
C-s&search forward incrementally\cr
C-r&search backward incrementally\cr
i&search index \& go to corresponding node\cr
,&go to next match from last `i' command\cr
\endsec

\sec Command-Line Cursor Motion;
C-b&move back one character\cr
C-f&move forward one character\cr
C-a&move to the start of the line\cr
C-e&move to the end of the line\cr
M-f&move forward a word\cr
M-b&move backward a word\cr
C-l&clear screen, reprinting current line at top\cr
\endsec

\sec Inserting or Changing Text;
M-TAB&insert a tab character\cr
DEL&delete character to the left of the cursor\cr
C-d&delete character under the cursor\cr
C-v&add the next character verbatim\cr
C-t&transpose characters at the point\cr
M-t&transpose words at the point\cr
% M-u&uppercase the current word\cr
% M-l&lowercase the current word\cr
% M-c&capitalize the current word\cr
\endsec

\vfill
\line{\smrm \opt{ } surround optional arguments
  \hfill ... show one or more arguments}
\vskip0.25\baselineskip
\eject

\sec Killing and Yanking;
C-k&kill to the end of the line\cr
C-y&yank the most recently killed text\cr
M-d&kill to the end of the current word\cr
M-DEL&kill the word behind the cursor\cr
M-y&rotate the kill ring and yank the new top\cr
\endsec

\sec Command Completion and History;
TAB&complete a command or variable name\cr
M-?&list possible completions\cr

RET&enter the current line \cr
C-p&move `up' through the history list\cr
C-n&move `down' through the history list\cr
M-<&move to the first line in the history\cr
M->&move to the last line in the history\cr
C-r&search backward in the history list\cr
C-s&search forward in the history list\cr

history \opt{{-q}} \opt{{\it N\/}}&list {\it N\/} previous history lines,
  omitting history numbers if {\tt -q}\cr
history -w \opt{{\it file}}&write history to {\it file\/} ({\tt
  \char'0176/.octave\_hist} if no {\it file\/} argument)\cr
history -r \opt{{\it file}}&read history from {\it file\/} ({\tt
  \char'0176/.octave\_hist} if no {\it file\/} argument)\cr

edit\_history {\it lines}&edit and then run previous
  commands from the history list\cr
run\_history {\it lines}&run previous commands from the
  history list\cr
\quad\opt{{\it beg\/}} \opt{{\it end\/}}&Specify the first and last
  history commands to edit or run.\cr
\omit\hfill\vbox{\hsize=\idnwid\rm\vskip0.25ex
  If {\it beg}\/ is greater than {\it end},
  reverse the list of commands before editing.  If {\it end\/} is
  omitted, select commands from {\it beg\/} to the end of the history
  list.  If both arguments are omitted, edit the previous item in the
  history list.}\span\cr
\endsec

\sec Shell Commands;
cd {\it dir}&change working directory to {\it dir}\cr
pwd&print working directory\cr
ls \opt{{\it options}}&print directory listing\cr
getenv ({\it string})&return value of named environment variable\cr
system ({\it cmd})&execute arbitrary shell command string\cr
\endsec

\sec Matrices;
\omit\vbox{\rm\vskip0.25ex
  Square brackets delimit literal matrices.  Commas separate elements
  on the same row.  Semicolons separate rows.  Commas may be replaced
  by spaces, and semicolons may be replaced by one or more newlines.
  Elements of a matrix may be arbitrary expressions, assuming
  all the dimensions agree.\vskip0.75ex}\span\cr
[ {\it x}, {\it y}, ... ]&enter a row vector\cr
[ {\it x}; {\it y}; ... ]&enter a column vector\cr
[ {\it w}, {\it x}; {\it y}, {\it z} ]&enter a 2$\times$2 matrix\cr
\endsec

\sec Multi-dimensional Arrays;
\omit\vbox{\rm\vskip0.25ex
  Multi-dimensional arrays may be created with the {\it cat} or
  {\it reshape} commands from two-dimensional sub-matrices.
  \vskip0.75ex}\span\cr
squeeze ({\it arr})&remove singleton dimensions of the array.\cr
ndims ({\it arr})&number of dimensions in the array.\cr
permute ({\it arr}, {\it p})&permute the dimensions of an array.\cr
ipermute ({\it arr}, {\it p})&array inverse permutation.\cr
\endsec

\vfill\eject

\sec ;
shiftdim ({\it arr}, {\it s})&rotate the array dimensions.\cr
circshift ({\it arr}, {\it s})&rotate the array elements.\cr
\endsec

\sec Sparse Matrices;
sparse (...)&create a sparse matrix.\cr
speye ({\it n)}&create sparse identity matrix.\cr
sprand ({\it n}, {\it m}, {\it d})&sparse rand matrix of density {\it d}.\cr
spdiags (...)&sparse generalization of {\it diag}.\cr
nnz ({\it s})&No. nonzero elements in sparse matrix.\cr
\endsec

\sec Ranges;
{\it base} : {\it limit}\cr
{\it base} : {\it incr} : {\it limit}\cr
\omit\hfill\vbox{\hsize=\idnwid\rm\vskip0.75ex
  Specify a range of values beginning with {\it base\/} with no elements
  greater than {\it limit}.  If it is omitted, the default value of
  {\it incr\/} is 1.  Negative increments are permitted.}\span\cr
\endsec

\sec Strings and Common Escape Sequences;
\omit\vbox{\rm\vskip0.5ex
  A {\it string constant\/} consists of a sequence of characters
  enclosed in either double-quote or single-quote marks. Strings
  in double-quotes allow the use of the escape sequences below.
  \vskip0.75ex}\span\cr
\char'134\char'134&a literal backslash\cr
\char'134 "&a literal double-quote character\cr
\char'134 '&a literal single-quote character\cr
\char'134 n&newline, ASCII code 10\cr
\char'134 t&horizontal tab, ASCII code 9\cr
\endsec

\sec Index Expressions;
{\it var} ({\it idx})&select elements of a vector\cr
{\it var} ({\it idx1}, {\it idx2})&select elements of a matrix\cr

\quad {\it scalar}&select row (column) corresponding to {\it scalar}\cr
\quad {\it vector}&select rows (columns) corresponding to the elements
  of {\it vector}\cr
\quad {\it range}&select rows (columns) corresponding to the elements
  of {\it range}\cr
\quad :&select all rows (columns)\cr
\endsec

\sec Global and Persistent Variables;
global {\it var1} ...&Declare variables global.\cr
global {\it var1} = {\it val}&Declare variable global. Set initial value.\cr
persistent {\it var1}&Declare a variable as static to a function.\cr
persistent {\it var1} = {\it val}&Declare a variable as static to a
  function and set its initial value.\cr
\omit\hfill\vbox{\rm\vskip0.25ex
  Global variables may be accessed inside the body of a function
  without having to be passed in the function parameter list provided
  they are declared global when used.}\span\cr
\endsec

\sec Selected Built-in Functions;
EDITOR&editor to use with {\tt edit\_history}\cr
Inf, NaN&IEEE infinity, NaN\cr
NA&Missing value\cr
PAGER&program to use to paginate output\cr
ans&last result not explicitly assigned\cr
eps&machine precision\cr
pi&$\pi$\cr
1i&$\sqrt{-1}$\cr
realmax&maximum representable value\cr
realmin&minimum representable value\cr
\endsec

\vfill
\centerline{\smrm Copyright 1996, 1997, 2007 John W. Eaton\qquad Permissions on back}
\eject

\sec Assignment Expressions;
{\it var} = {\it expr}&assign expression to variable\cr
{\it var} ({\it idx}) = {\it expr}&assign expression to indexed variable\cr
{\it var} ({\it idx}) = []&delete the indexed elements.\cr
{\it var} $\{${\it idx}$\}$ = {\it expr}&assign elements of a cell array.\cr
\endsec

\sec Arithmetic and Increment Operators;
{\it x} + {\it y}&addition\cr
{\it x} - {\it y}&subtraction\cr
{\it x} * {\it y}&matrix multiplication\cr
{\it x} .* {\it y}&element by element multiplication\cr
{\it x} / {\it y}&right division, conceptually equivalent to
  {\tt (inverse~(y')~*~x')'}\cr
{\it x} ./ {\it y}&element by element right division\cr
{\it x} \char'134{} {\it y}&left division, conceptually equivalent to
  {\tt inverse~(x)~*~y}\cr
{\it x} .\char'134{} {\it y}&element by element left division\cr
{\it x} \char'136{} {\it y}&power operator\cr
{\it x} .\char'136{} {\it y}&element by element power operator\cr
- {\it x}&negation\cr
+ {\it x}&unary plus (a no-op)\cr
{\it x} '&complex conjugate transpose\cr
{\it x} .'&transpose\cr
++ {\it x}\quad{\rm(}-- {\it x}{\rm)}&increment (decrement),
  return {\it new\/} value\cr
{\it x} ++\quad{\rm(}{\it x} --{\rm)}&increment (decrement),
  return {\it old\/} value\cr
\endsec

\sec Comparison and Boolean Operators;
\omit \vbox{\rm\vskip0.75ex
  These operators work on an element-by-element basis.  Both arguments
  are always evaluated.\vskip0.75ex}\span\cr
{\it x} < {\it y}&true if {\it x\/} is less than {\it y}\cr
{\it x} <= {\it y}&true if {\it x\/} is less than or equal to {\it y}\cr
{\it x} == {\it y}&true if {\it x\/} is equal to {\it y}\cr
{\it x} >= {\it y}&true if {\it x\/} is greater than or equal to {\it y}\cr
{\it x} > {\it y}&true if {\it x\/} is greater than {\it y}\cr
{\it x} != {\it y}&true if {\it x\/} is not equal to {\it y}\cr
{\it x} \& {\it y}&true if both {\it x\/} and {\it y\/} are true\cr
{\it x} | {\it y}&true if at least one of {\it x\/} or {\it y\/} is true\cr
! {\it bool}&true if {\it bool\/} is false\cr
\endsec

\sec Short-circuit Boolean Operators;
\omit \vbox{\rm\vskip0.75ex
  Operators evaluate left-to-right. Operands are only evaluated if
  necessary, stopping once overall truth value can be determined.
  Operands are converted to scalars using the {\tt all}
  function.\vskip0.75ex}\span\cr
{\it x} \&\& {\it y}&true if both {\it x\/} and {\it y\/} are true\cr
{\it x} || {\it y}&true if at least one of {\it x\/} or {\it y\/} is true\cr
\endsec

\sec Operator Precedence;
\omit \vbox{\rm\vskip0.5ex
  Table of Octave operators, in order of increasing
  precedence.\vskip0.75ex}\span\cr
;\ \ ,&statement separators\cr
=&assignment, groups left to right\cr
||\ \ \&\&&logical ``or'' and ``and''\cr
|\ \ \&&element-wise ``or'' and ``and''\cr
< <= == >= > !=&relational operators\cr
:&colon\cr
+\ \ -&addition and subtraction\cr
* / \char'134\ \ .*\ \ ./\ \ .\char'134&multiplication and division\cr
'\ \ .'&transpose\cr
+\ \ -\ \ ++\ \ --\ \ !&unary minus, increment, logical ``not''\cr
\char'136\ \ .\char'136&exponentiation\cr
\endsec

\vfill\eject

\sec Paths and Packages;
path&display the current Octave function path.\cr
pathdef&display the default path.\cr
addpath ({\it dir})&add a directory to the path.\cr
EXEC\_PATH&manipulate the Octave executable path.\cr
pkg list&display installed packages.\cr
pkg load {\it pack}&Load an installed package.\cr
\endsec

\sec Cells and Structures;
{\it{var}}.{\it{field}} = ...&set a field of a structure.\cr
{\it{var}}$\{${\it{idx}}$\}$ = ...&set an element of a cell array.\cr
cellfun ({\it f}, {\it c})&apply a function to elements of cell array.\cr
fieldnames ({\it s})&returns the fields of a structure.\cr
\endsec

\widesec Statements;
for {\it identifier} = {\it expr} {\it stmt-list} endfor\cr
\hfill\vbox{\hsize=\idnwid\rm\vskip0.25ex
  Execute {\it stmt-list} once for each column of {\it expr}.  The
  variable {\it identifier} is set to the value of the current column
  during each iteration.}\cr\cr
while ({\it condition}) {\it stmt-list} endwhile\cr
\hfill\vbox{\hsize=\idnwid\rm\vskip0.25ex
  Execute {\it stmt-list} while {\it condition} is true.}\cr\cr
\hbox{\vtop{\hsize=\itmwid\tt break}
  \vtop{\hsize=\dfnwid\rm exit innermost loop}}\cr
\hbox{\vtop{\hsize=\itmwid\tt continue}
  \vtop{\hsize=\dfnwid\rm go to beginning of innermost loop}}\cr
\hbox{\vtop{\hsize=\itmwid\tt return}
  \vtop{\hsize=\dfnwid\rm return to calling function}}\cr\cr
if ({\it condition}) {\it if-body} \opt{{\tt else} {\it else-body}} endif\cr
\hfill\vbox{\hsize=\idnwid\rm\vskip0.25ex
  Execute {\it if-body} if {\it condition} is true, otherwise execute
  {\it else-body}.}\cr
if ({\it condition}) {\it if-body} \opt{{\tt elseif} ({\it condition})
  {\it elseif-body}} endif\cr
\hfill\vbox{\hsize=\idnwid\rm\vskip0.25ex
  Execute {\it if-body} if {\it condition} is true, otherwise execute
  the {\it elseif-body} corresponding to the first {\tt elseif}
  condition that is true, otherwise execute {\it else-body}.}\cr
\hfill\vbox{\hsize=\idnwid\rm\vskip0.25ex
  Any number of {\tt elseif} clauses may appear in an {\tt if}
  statement.}\cr\cr
unwind\_protect {\it body} unwind\_protect\_cleanup {\it cleanup} end\cr
\hfill\vbox{\hsize=\idnwid\rm\vskip0.25ex
  Execute {\it body}.  Execute {\it cleanup} no matter how control
exits {\it body}.}\cr
try {\it body} catch {\it cleanup} end\cr
\hfill\vbox{\hsize=\idnwid\rm\vskip0.25ex
  Execute {\it body}. Execute {\it cleanup} if {\it body} fails.}\cr
\endsec

\altsec Strings;
strcmp ({\it s}, {\it t})&compare strings\cr
strcat ({\it s}, {\it t}, ...)&concatenate strings\cr
regexp ({\it str}, {\it pat})&strings matching regular expression\cr
regexprep ({\it str}, {\it pat}, {\it rep})&Match and replace sub-strings\cr
\endsec

\widesec Defining Functions;
function \opt{{\it ret-list}} {\it function-name}
  \opt{\hskip0.2em({\it arg-list})\hskip0.2em}\cr
\quad{\it function-body}\cr
endfunction\cr\cr
{\rm {\it ret-list\/} may be a single identifier or a comma-separated
  list of identifiers delimited by square-brackets.\vskip0.75ex}\cr
{\rm {\it arg-list\/} is a comma-separated list of identifiers and may
  be empty.}\cr
\endsec

\vfill\eject

\sec Function Handles;
@{\it{func}}& Define a function handle to {\it func}.\cr
@({\it var1}, ...) {\it expr}&Define an anonymous function handle.\cr
str2func ({\it str})&Create a function handle from a string.\cr
functions ({\it handle})&Return information about a function handle.\cr
func2str ({\it handle})&Return a string representation of a
function handle.\cr
{\it handle} ({\it arg1}, ...)&Evaluate a function handle.\cr
feval ({\it func}, {\it arg1}, ...)&Evaluate a function handle or
  string, passing remaining args to {\it func}\cr
\omit\vbox{\rm\vskip0.25ex
  Anonymous function handles take a copy of the variables in the
  current workspace.\vskip0.75ex}\span\cr
\endsec

\sec Miscellaneous Functions;
eval ({\it str})&evaluate {\it str} as a command\cr
error ({\it message})&print message and return to top level\cr
warning ({\it message})&print a warning message\cr
clear {\it pattern}&clear variables matching pattern\cr
exist ({\it str})&check existence of variable or function\cr
who, whos&list current variables\cr
whos {\it var}&details of the variable {\it var}\cr
\endsec

\sec Basic Matrix Manipulations;
rows ({\it a})&return number of rows of {\it a}\cr
columns ({\it a})&return number of columns of {\it a}\cr
all ({\it a})&check if all elements of {\it a\/} nonzero\cr
any ({\it a})&check if any elements of {\it a\/} nonzero\cr
\endsec

\sec ;
find ({\it a})&return indices of nonzero elements\cr
sort ({\it a})&order elements in each column of {\it a}\cr
sum ({\it a})&sum elements in columns of {\it a}\cr
prod ({\it a})&product of elements in columns of {\it a}\cr
min ({\it args})&find minimum values\cr
max ({\it args})&find maximum values\cr
rem ({\it x}, {\it y})&find remainder of {\it x}/{\it y}\cr
reshape ({\it a}, {\it m}, {\it n})&reformat {\it a} to be {\it m} by
  {\it n}\cr
diag ({\it v}, {\it k})&create diagonal matrices\cr
linspace ({\it b}, {\it l}, {\it n})&create vector of linearly-spaced
  elements\cr
logspace ({\it b}, {\it l}, {\it n})&create vector of log-spaced
  elements\cr
eye ({\it n}, {\it m})&create {\it n\/} by {\it m\/} identity matrix\cr
ones ({\it n}, {\it m})&create {\it n\/} by {\it m\/} matrix of ones\cr
zeros ({\it n}, {\it m})&create {\it n\/} by {\it m\/} matrix of zeros\cr
rand ({\it n}, {\it m})&create {\it n\/} by {\it m\/} matrix of random
  values\cr
\endsec

% sin ({\it a}) cos({\it a}) tan({\it a})&trigonometric functions\cr
% asin ({\it a}) acos({\it a}) atan({\it a})&inverse trigonometric functions\cr
% sinh ({\it a}) cosh({\it a}) tanh({\it a})&hyperbolic trig functions\cr
% asinh ({\it a}) acosh({\it a}) atanh({\it a})&inverse hyperbolic trig
% functions\cr\cr

\sec Linear Algebra;
chol ({\it a})&Cholesky factorization\cr
det ({\it a})&compute the determinant of a matrix\cr
eig ({\it a})&eigenvalues and eigenvectors\cr
expm ({\it a})&compute the exponential of a matrix\cr
hess ({\it a})&compute Hessenberg decomposition\cr
inverse ({\it a})&invert a square matrix\cr
norm ({\it a}, {\it p})&compute the {\it p}-norm of a matrix\cr
pinv ({\it a})&compute pseudoinverse of {\it a}\cr
qr ({\it a})&compute the QR factorization of a matrix\cr
rank ({\it a})&matrix rank\cr
sprank ({\it a})&structural matrix rank\cr
schur ({\it a})&Schur decomposition of a matrix\cr
svd ({\it a})&singular value decomposition\cr
syl ({\it a}, {\it b}, {\it c})&solve the Sylvester equation\cr
\endsec

\vfill\eject

\sec Equations, ODEs, DAEs, Quadrature;
*fsolve&solve nonlinear algebraic equations\cr
*lsode&integrate nonlinear ODEs\cr
*dassl&integrate nonlinear DAEs\cr
*quad&integrate nonlinear functions\cr
perror ({\it nm}, {\it code})&for functions that return numeric
  codes, print error message for named function and given error
  code\cr\cr
\omit \vbox{\rm
  {\tt *} See the on-line or printed manual for the complete list of
  arguments for these functions.}\span\cr
\endsec

% \altsec Sets;
% create\_set ({\it a}, {\it b})&create row vector of unique values\cr
% complement ({\it a}, {\it b})&elements of {\it b} not in {\it a}\cr
% intersection ({\it a}, {\it b})&intersection of sets {\it a} and {\it b}\cr
% union ({\it a}, {\it b})&union of sets {\it a} and {\it b}\cr
% \endsec

\sec Signal Processing;
fft ({\it a})&Fast Fourier Transform using FFTW\cr
ifft ({\it a})&inverse FFT using FFTW\cr
freqz ({\it args})&FIR filter frequency response\cr
filter ({\it a}, {\it b}, {\it x})&filter by transfer function\cr
conv ({\it a}, {\it b})&convolve two vectors\cr
hamming ({\it n})&return Hamming window coefficients\cr
hanning ({\it n})&return Hanning window coefficients\cr
\endsec

\altsec Image Processing;
colormap ({\it map})&set the current colormap\cr
gray2ind ({\it i}, {\it n})&convert gray scale to Octave image\cr
image ({\it img}, {\it zoom})&display an Octave image matrix\cr
imagesc ({\it img}, {\it zoom})&display scaled matrix as image\cr
imread ({\it file})&load an image file\cr
imshow ({\it img}, {\it map})&display Octave image\cr
imshow ({\it i}, {\it n})&display gray scale image\cr
imshow ({\it r}, {\it g}, {\it b})&display RGB image\cr
imwrite ({\it img}, {\it file})&write images in various file formats\cr
ind2gray ({\it img}, {\it map})&convert Octave image to gray scale\cr
ind2rgb ({\it img}, {\it map})&convert indexed image to RGB\cr
rgb2ind ({\it r}, {\it g}, {\it b})&convert RGB to Octave image\cr
save a matrix to {\it file}\span\cr
\endsec

\altsec C-style Input and Output;
fopen ({\it name}, {\it mode})&open file {\it name}\cr
fclose ({\it file})&close {\it file}\cr
printf ({\it fmt}, ...)&formatted output to {\tt stdout}\cr
fprintf ({\it file}, {\it fmt}, ...)&formatted output to {\it file}\cr
sprintf ({\it fmt}, ...)&formatted output to string\cr
scanf ({\it fmt})&formatted input from {\tt stdin}\cr
fscanf ({\it file}, {\it fmt})&formatted input from {\it file}\cr
sscanf ({\it str}, {\it fmt})&formatted input from {\it string}\cr
fgets ({\it file}, {\it len})&read {\it len\/} characters from {\it file\/}\cr
fflush ({\it file})&flush pending output to {\it file}\cr
ftell ({\it file})&return file pointer position\cr
frewind ({\it file})&move file pointer to beginning\cr
freport&print a info for open files\cr
fread ({\it file}, {\it size}, {\it prec})&read binary data files\cr
fwrite ({\it file}, {\it size}, {\it prec})&write binary data files\cr
feof ({\it file})&determine if pointer is at EOF\cr
\omit \vbox{\rm\vskip0.75ex
  A file may be referenced either by name or by the number returned
  from {\tt fopen}.  Three files are preconnected when Octave starts:
  {\tt stdin}, {\tt stdout}, and {\tt stderr}.\vskip0.75ex}\span\cr
\endsec

\sec Other Input and Output functions;
save {\it file} {\it var} ...&save variables in {\it file}\cr
load {\it file}&load variables from {\it file}\cr
disp ({\it var})&display value of {\it var} to screen\cr
\endsec

\vfill\eject

\sec Polynomials;
compan ({\it p})&companion matrix\cr
conv ({\it a}, {\it b})&convolution\cr
deconv ({\it a}, {\it b})&deconvolve two vectors\cr
poly ({\it a})&create polynomial from a matrix\cr
polyderiv ({\it p})&derivative of polynomial\cr
polyreduce ({\it p})&integral of polynomial\cr
polyval ({\it p}, {\it x})&value of polynomial at {\it x}\cr
polyvalm ({\it p}, {\it x})&value of polynomial at {\it x}\cr
roots ({\it p})&polynomial roots\cr
residue ({\it a}, {\it b})&partial fraction expansion of
ratio {\it a}/{\it b}\cr
\endsec

\sec Statistics;
corrcoef ({\it x}, {\it y})&correlation coefficient\cr
cov ({\it x}, {\it y})&covariance\cr
mean ({\it a})&mean value\cr
median ({\it a})&median value\cr
std ({\it a})&standard deviation\cr
var ({\it a})&variance\cr
\endsec

\sec Plotting Functions;
plot ({\it args})&2D plot with linear axes\cr
plot3 ({\it args})&3D plot with linear axes\cr
line ({\it args})&2D or 3D line\cr
patch ({\it args})&2D patch\cr
semilogx ({\it args})&2D plot with logarithmic x-axis\cr
semilogy ({\it args})&2D plot with logarithmic y-axis\cr
loglog ({\it args})&2D plot with logarithmic axes\cr
bar ({\it args})&plot bar charts\cr
stairs ({\it x}, {\it y})&plot stairsteps\cr
stem ({\it x}, {\it y})&plot a stem graph\cr
hist ({\it y}, {\it x})&plot histograms\cr
contour ({\it x}, {\it y}, {\it z})&contour plot\cr
title ({\it string})&set plot title\cr
axis ({\it limits})&set axis ranges\cr
xlabel ({\it string})&set x-axis label\cr
ylabel ({\it string})&set y-axis label\cr
zlabel ({\it string})&set z-axis label\cr
text ({\it x}, {\it y}, {\it str})&add text to a plot\cr
legend ({\it string})&set label in plot key\cr
grid \opt{on$|$off}&set grid state\cr
hold \opt{on$|$off}&set hold state\cr
ishold&return 1 if hold is on, 0 otherwise\cr
mesh ({\it x}, {\it y}, {\it z})&plot 3D surface\cr
meshgrid ({\it x}, {\it y})&create mesh coordinate matrices\cr
\endsec

\vskip 0pt plus 2fill
\hrule width \hsize
\par\vskip10pt
{\smrm\parskip=6pt
Edition \refcardedition\ for Octave Version \octaveversion.  Copyright
1996, 2007, John W. Eaton
(jwe@octave.org).  The author assumes no responsibility for any
errors on this card.

This card may be freely distributed under the terms of the GNU
General Public License.

\TeX{} Macros for this card by Roland Pesch (pesch@cygnus.com),
originally for the GDB reference card

Octave itself is free software; you are welcome to distribute copies of
it under the terms of the GNU General Public License.  There is
absolutely no warranty for Octave.
}

\end

% For AUCTeX:
%
% Local Variables:
% mode: tex
% TeX-master: t
% End: