changeset 31272:3e4b9ecc031c

doc: More changes to refcard.tex refcard.tex: Add switch-case, add classdef, consolidate several sections into one to make space for content, add more functions, add note about how to discover more functions, fixed two formatting issues.
author Arun Giridhar <arungiridhar@gmail.com>
date Fri, 07 Oct 2022 13:39:08 -0400
parents 6cf7dab21e9b
children 5f536c6a9bd6
files doc/refcard/refcard.tex
diffstat 1 files changed, 140 insertions(+), 134 deletions(-) [+]
line wrap: on
line diff
--- a/doc/refcard/refcard.tex	Fri Oct 07 06:55:19 2022 -0400
+++ b/doc/refcard/refcard.tex	Fri Oct 07 13:39:08 2022 -0400
@@ -56,7 +56,7 @@
 % covered, nor all variations of a command.
 
 \def\octaveversion{8.0.0}
-\def\refcardedition{3.0}
+\def\refcardedition{3.1}
 
 % ------------------
 % multicolumn format
@@ -379,16 +379,14 @@
 % -------------------------------------
 
 {\vbbf Octave Quick Reference}\hfil{\smrm Octave Version \octaveversion}\qquad
-\centerline{\smrm Copyright 1996-2022 The Octave Project Developers\qquad Permissions on back}
+\centerline{\smrm Copyright 1996-2022 The Octave Project Developers
+\qquad Permissions on back}
 
-\sec Starting Octave;
+\sec Starting And Stopping;
 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
 Ctrl-C&terminate current command and return to top-level prompt\cr
 \endsec
@@ -412,17 +410,17 @@
 ls \opt{{\it options}}&print directory listing\cr
 getenv ({\it string})&return value of named environment variable\cr
 what&list .m and .mat files in the current directory\cr
-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
+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
 \endsec
 
 \sec Package Management;
 pkg install -forge&download and install package\cr
 pkg install &install an already downloaded package\cr
-pkg list&display installed packages.\cr
-pkg load / pkg unload &Load and unload an installed package.\cr
+pkg list&display installed packages\cr
+pkg load / pkg unload &Load and unload an installed package\cr
 \endsec
 
 \sec Matrices;
@@ -444,18 +442,18 @@
 rand randi randn&create matrix of random values\cr
 all&true if all elements nonzero\cr
 any&true if at least one element nonzero\cr
-nnz ({\it s})&Count nonzero elements of {\it s}.\cr
+nnz &ount nonzero elements\cr
 sparse&create a sparse matrix\cr
 \endsec
 
 \sec Multi-dimensional Arrays;
-cat&concatenate variables along the specified dimension\cr
-reshape&change the shape of vector or matrix or array\cr
+cat&concatenate along a given dimension\cr
+reshape&change the shape of an array\cr
 squeeze&remove singleton dimensions\cr
 ndims&number of dimensions\cr
-permute, ipermute, shiftdim&permute the dimensions of an array, like a generalized transpose\cr
-circshift&rotate the array elements\cr
-meshgrid&create coordinate matrices useful for vectorization\cr
+permute, ipermute, shiftdim&like N-dimensional transpose\cr
+circshift&cyclically shift array elements\cr
+meshgrid&matrices useful for vectorization\cr
 \endsec
 
 \sec Ranges;
@@ -469,15 +467,15 @@
 \omit\vbox{\rm\vskip0.5ex
   Integers saturate in Octave. They do not wrap around.
   \vskip0.75ex}\span\cr
-int8, int16, int32, int64&Signed integers\cr
-uint8, uint16, uint32, uint64&Unsigned integers\cr
-single double&32-bit / 64-bitIEEE floating point\cr
-intmin, intmax, flintmax&Integer limits of given type\cr
-realmax, realmin&Floating point limits of given type\cr
-Inf, NaN, NA&IEEE infinity, NaN, missing value\cr
+int8 int16 int32 int64&Signed integers\cr
+uint8 uint16 uint32 uint64&Unsigned integers\cr
+single double&32-bit / 64-bit IEEE floating point\cr
+intmin intmax, flintmax&Integer limits of given type\cr
+realmax realmin&Floating point limits of given type\cr
+inf nan NA&IEEE infinity, NaN, missing value\cr
 eps&machine precision\cr
-pi, e&3.14159..., 2.71828...\cr
-i, j&$\sqrt{-1}$\cr
+pi e&3.14159..., 2.71828...\cr
+i j&$\sqrt{-1}$\cr
 \endsec
 
 \sec Strings;
@@ -491,43 +489,47 @@
 \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
-sprintf, sscanf&formatted IO to/from string\cr
+sprintf sscanf&formatted IO to/from string\cr
 strcmp&compare strings\cr
 strcat&concatenate strings\cr
-strfind, regexp&strings matching substrings or regular expressions\cr
-strrep, regexprep&match and replace sub-strings\cr
+strfind regexp&find matching patterns\cr
+strrep regexprep&find and replace patterns\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
-{\it var} ({\it [1 3]}, {\it :})&rows 1 and 3\cr
-{\it var} ({\it :}, {\it [2 end]})&the second and last columns\cr
-{\it var} ({\it 1:2:end}, {\it 2:2:end})&submatrix with odd rows and even columns\cr
-{\it var1} ({\it var2} == 0)&elements of {\it var1} corresponding to zero elements of {\it var2}\cr
-{\it var} ({:})&all elements as a column vector\cr
+{\it var}({\it idx})&select elements of a vector\cr
+{\it var}({\it idx1}, {\it idx2})&select elements of a matrix\cr
+{\it var}({\it [1 3]}, {\it :})&rows 1 and 3\cr
+{\it var}({\it :}, {\it [2 end]})&the second and last columns\cr
+{\it var}({\it 1:2:end}, {\it 2:2:end})&get odd rows and even columns\cr
+{\it var1}({\it var2} == 0)&elements of {\it var1} corresponding to zero
+elements of {\it var2}\cr
+{\it var}({:})&all elements as a column vector\cr
 \endsec
 
-\sec Cells and Structures;
-%
-% FIXME add classdef to this section?
-%
-{\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
+\sec Cells, Structures, and Classdefs;
+{\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
+classdef&define new classes for OOP\cr
 \endsec
 
 \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
+{\it var} = {\it expr}&assign value to variable\cr
+{\it var}({\it idx}) = {\it expr}&only the indexed elements are changed\cr
+{\it var}({\it idx}) = []&delete the indexed elements\cr
 \endsec
 
 \sec Arithmetic Operators;
+%
+% FIXME These operators look ugly, but putting them in math mode causes
+% some of them to break even more.
+%
 \omit \vbox{\rm\vskip0.75ex
-  If two operands are of different sizes, scalars and singleton dimensions are automatically expanded. Non-singleton dimensions need to match.\vskip0.75ex}\span\cr
+  If two operands are of different sizes, scalars and singleton dimensions are
+  automatically expanded. Non-singleton dimensions need to match.
+  \vskip0.75ex}\span\cr
 {\it x} + {\it y}, {\it x} - {\it y}&addition, subtraction\cr
 {\it x} * {\it y}&matrix multiplication\cr
 {\it x} .* {\it y}&element by element multiplication\cr
@@ -539,42 +541,42 @@
 {\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
-+=, -=, *=, .*=, /=, ./=, \char'134{}=, .\char'134{}=, \char'136{}=, .\char'136{}=&in-place equivalents of the above operators\cr
++= -= *= .*= /= ./= \char'134{}= .\char'134{}= \char'136{}= .\char'136{}=&
+in-place equivalents of the above operators\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}, --{\it x}&increment / decrement, return {\it new\/} value\cr
-{\it x}++, {\it x}--&increment / decrement, return {\it old\/} value\cr
+{\it x}$'$&complex conjugate transpose\cr
+{\it x}.$'$&transpose\cr
+++{\it x} --{\it x}&increment / decrement, return {\it new\/} value\cr
+{\it x}++ {\it x}--&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
-< <= == >= >&less than, less than or equal to, equal to, greater than or equal to, greater than\cr
-%
-% FIXME add ~= and ~. TeX mangles the tilde and escaping with \ or {} does not help.
-%
-!=&not equal to\cr
-\&&logical AND\cr
-|&logical OR\cr
-!&logical NOT\cr
+< <= == >= >&relational operators\cr
+!= \char'176 =&not equal to\cr
+\& &logical AND\cr
+|  &logical OR\cr
+! \char'176 &logical NOT\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
+  Non-scalar operands are converted to scalars with
+  {\tt all}.\vskip0.75ex}\span\cr
+{\it x} \&\& {\it y}&logical AND\cr
+{\it x} || {\it y}&logical OR\cr
 \endsec
 
+\vfill\eject
+
 \sec Operator Precedence;
 \omit \vbox{\rm\vskip0.5ex
-  Table of Octave operators, in order of increasing
+  Table of Octave operators, in order of {\tt increasing}
   precedence.\vskip0.75ex}\span\cr
 ;\ \ ,&statement separators\cr
 =&assignment, groups left to right\cr
@@ -614,18 +616,29 @@
 
 endif & if-then-else\cr
 
+switch (tf)
+
+case "true"
+
+case "false"
+
+otherwise
+
+endswitch & switch-case\cr
+
 break & exit innermost loop\cr
 
-continue & go to beginning of innermost loop\cr
+continue & go to start of innermost loop\cr
 
-return & return to calling function\cr
+return & jump back to calling location\cr
+
+try
 
-%
-% FIXME: insert underscore for unwind_protect / unwind_protect_cleanup without TeX choking.
-%
-unwind protect & execute cleanup code always\cr
+catch & cleanup only on exception\cr
 
-try catch & execute cleanup code only if exception occurs\cr
+unwind\char'137 protect
+
+unwind\char'137 protect\char'137 cleanup & cleanup always \cr
 \endsec
 
 \widesec Functions;
@@ -640,11 +653,11 @@
 \endsec
 
 \sec Function Handles;
-@{\it{func}}& define a function handle to {\it func}.\cr
+@{\it{func}}& define a function handle to {\it func}\cr
 @({\it var1}, ...) {\it expr}&define an anonymous function\cr
 str2func func2str&convert function to/from string\cr
-functions ({\it handle})&Return information about a function handle.\cr
-{\it handle} ({\it arg1}, ...)&Evaluate a function handle.\cr
+functions ({\it handle})&Return information about a function handle\cr
+{\it handle} ({\it arg1}, ...)&Evaluate a function handle\cr
 feval &Evaluate a function handle or string\cr
 \omit\vbox{\rm\vskip0.25ex
   Anonymous function handles take a copy of the variables in the
@@ -669,12 +682,11 @@
 exist&check existence of variable or function\cr
 find&return indices of nonzero elements\cr
 sort&return a sorted array\cr
+unique&discard duplicate elements\cr
 sortrows&sort whole rows in numerical or lexicographic order\cr
-sum, prod&sum, product of elements\cr
-mod, rem&remainder functions\cr
-min, max, range, mean, median, mode, std, var&basic statistics functions\cr
-cov ({\it x}, {\it y})&covariance\cr
-corrcoef ({\it x}, {\it y})&correlation coefficient\cr
+sum prod&sum or product\cr
+mod rem&remainder functions\cr
+min max range mean median std&basic statistics\cr
 \endsec
 
 \sec Error Handling;
@@ -685,85 +697,79 @@
 \endsec
 
 \sec File I/O, Loading, Saving;
-fopen, fclose & open and close file\cr
-fprintf, fscanf, textscan&formatted file I/O\cr
-fgets, fread&read from file\cr
-fputs, fwrite&write to file\cr
-fflush&flush pending output\cr
-feof&true if end of file\cr
-
-save, load &save or load variables to or from file\cr
+save load &save or load variables to or from file\cr
 save -binary &save variables in binary format (faster)\cr
 dlmread dlmwrite&read and write delimited data\cr
 csvread csvwrite&read and write CSV files\cr
 xlsread xlswrite&read and write XLS spreadsheets\cr
+
+fopen fclose & open and close file\cr
+fprintf fscanf textscan&formatted file I/O\cr
+fflush&flush pending output\cr
 \endsec
 
-\sec Linear Algebra;
-det & determinant\cr
+\sec Math Functions;
+\omit \vbox{\rm\vskip0.5ex
+  Run {\tt doc <function>} to find related functions.
+  \vskip0.75ex}\span\cr
+cov corrcoef&covariance, correlation coefficient\cr
+tan tanh atan2&trig and hyperbolic functions\cr
+cross curl del2&vector algebra functions\cr
+&\cr
+det inv& determinant matrix inverse\cr
 eig &eigenvalues and eigenvectors\cr
-inv &matrix inverse\cr
 norm &vector norm, matrix norm\cr
 rank &matrix rank\cr
 qr &QR factorization\cr
 chol &Cholesky factorization\cr
 svd &singular value decomposition\cr
-\endsec
-
-\sec Equations, ODEs, DAEs, Quadrature;
+&\cr
 fsolve&solve nonlinear algebraic equations\cr
 lsode&integrate nonlinear ODEs\cr
 dassl&integrate nonlinear DAEs\cr
 quad&integrate nonlinear functions\cr
-\endsec
-
-\sec Sets;
-setdiff&set difference\cr
-intersection&set intersection\cr
+&\cr
 union&set union\cr
-unique&discard duplicate elements\cr
-\endsec
-
-\sec Signal Processing;
-fft, ifft({\it a})&FFT and inverse FFT\cr
+intersection&set intersection\cr
+setdiff&set difference\cr
+&\cr
+roots &polynomial roots\cr
+poly &matrix characteristic polynomial\cr
+polyder polyint&polynomial derivative or integral\cr
+polyfit polyval&polynomial fitting and evaluation\cr
+residue &partial fraction expansion\cr
+legendre bessel airy&special function\cr
+&\cr
+conv conv2& convolution, polynomial multiplication\cr
+deconv& deconvolution, polynomial division\cr
+&\cr
+fft fft2 ifft({\it a})&FFT and inverse FFT\cr
 freqz &FIR filter frequency response\cr
 filter &filter by transfer function\cr
-conv, deconv &convolution, deconvolution\cr
 \endsec
 
-\sec Polynomials;
-conv, deconv & polynomial multiplication and division\cr
-poly &characteristic polynomial of a matrix\cr
-polyder polyint&polynomial derivative or integral\cr
-polyfit polyval& fit polynomial to data and evaluate it\cr
-roots &polynomial roots\cr
-residue &partial fraction expansion\cr
-\endsec
-
-\sec Image Processing;
-colormap &set the current colormap\cr
-image, imagesc &display Octave image matrix, scaled\cr
-imread imwrite&load or save an image file\cr
-\endsec
-
-\sec Plotting Functions;
+\sec Plotting And Graphics;
 plot plot3 &2D / 3D plot with linear axes\cr
 line &2D or 3D line\cr
 patch fill&2D patch, optionally colored\cr
-semilogx semilogy loglog&2D plot with logarithmic x-axis / y-axis / both axes\cr
-bar &bar charts\cr
-stairs &plot stairsteps\cr
-stem &plot a stem graph\cr
-hist &plot histogram\cr
+semilogx semilogy loglog&2D plot with one or both axes on a log scale\cr
+bar hist&bar chart, histogram\cr
+stairs stem&stairsteps and stem graphs\cr
 contour &contour plot\cr
+mesh trimesh surf &plot 3D surfaces\cr
+&\cr
+figure&new figure\cr
+hold on&add to existing figure\cr
 title &set plot title\cr
-axis &set axis ranges\cr
-xlabel ylabel zlabel  &set axis labels\cr
+axis &set axis range and aspect\cr
+xlabel ylabel zlabel &set axis labels\cr
 text &add text to a plot\cr
-legend &make a legend box\cr
-grid &set grid state\cr
-hold &set hold state\cr
-mesh trimesh surf &plot 3D surfaces\cr
+grid legend &draw grid or legend\cr
+&\cr
+image imagesc spy&display matrix as image\cr
+imwrite saveas print&save figure or image\cr
+imread&load an image\cr
+colormap &get or set colormap\cr
 \endsec
 
 \vskip 0pt plus 2fill