Refcard Letter.
Refcard Letter.
Refcard Letter.
Starting Octave
octave
start interactive Octave session
octave file
run Octave on commands in file
octave --eval code Evaluate code using Octave
octave --help
describe command line options
exit Octave
(e.g. C-c) terminate current command
and return to top-level prompt
Getting Help
help
help command
doc
doc command
lookfor str
Searching in Info
s
C-s
C-r
i
,
[]
Sparse Matrices
sparse (...)
speye (n)
sprand (n, m, d)
spdiags (...)
nnz (s)
TAB
M-?
RET
C-p
C-n
M-<
M->
C-r
C-s
history [-q] [N ]
history -w [file]
Motion in Info
SPC or C-v
DEL or M-v
C-l
history -r [file]
[beg ] [end ]
Ranges
base : limit
base : incr : limit
Specify a range of values beginning with base with no
elements greater than limit. If it is omitted, the default
value of incr is 1. Negative increments are permitted.
\\
\"
\
\n
\t
Index Expressions
var (idx)
var (idx1, idx2)
scalar
vector
Shell Commands
cd dir
pwd
ls [options]
getenv (string)
system (cmd)
Matrices
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.
[ x, y, ... ]
[ x; y; ... ]
[ w, x; y, z ]
Multi-dimensional Arrays
Multi-dimensional arrays may be created with the cat or
reshape commands from two-dimensional sub-matrices.
squeeze (arr)
ndims (arr)
permute (arr, p)
ipermute (arr, p)
a literal backslash
a literal double-quote character
a literal single-quote character
newline, ASCII code 10
horizontal tab, ASCII code 9
range
Permissions on back
Assignment Expressions
Function Handles
var = expr
var (idx) = expr
var (idx) = []
path
pathdef
addpath (dir)
EXEC PATH
pkg list
pkg load pack
@func
Define a function handle to func.
@(var1, ...) expr Define an anonymous function handle.
str2func (str)
Create a function handle from a string.
functions (handle) Return information about a function
var
{idx} =
expr
+ y
- y
* y
.* y
/ y
addition
subtraction
matrix multiplication
element by element multiplication
right division, conceptually equivalent to
(inverse (y) * x)
x ./ y
x \ y
x .\ y
x ^ y
x .^ y
- x
+ x
x
x .
++ x (-- x)
x ++ (x --)
inverse (x) * y
< y
<= y
== y
>= y
> y
!= y
& y
| y
! bool
true
true
true
true
true
true
true
true
true
if
if
if
if
if
if
if
if
if
x is less than y
x is less than or equal to y
x is equal to y
x is greater than or equal to y
x is greater than y
x is not equal to y
both x and y are true
at least one of x or y is true
bool is false
Operator Precedence
Table of Octave operators, in order of increasing precedence.
; ,
=
|| &&
| &
< <= == >= > !=
:
+ * / \ .* ./ .\
.
+ - ++ -- !
^ .^
statement separators
assignment, groups left to right
logical or and and
element-wise or and and
relational operators
colon
addition and subtraction
multiplication and division
transpose
unary minus, increment, logical not
exponentiation
var{idx} = ...
cellfun (f, c)
fieldnames (s)
function handle.
handle (arg1, ...) Evaluate a function handle.
feval (func, arg1, Evaluate a function handle or string,
...)
passing remaining args to func
Anonymous function handles take a copy of the variables in
the current workspace.
Miscellaneous Functions
Statements
for identifier = expr stmt-list endfor
Execute stmt-list once for each column of expr. The
variable identifier is set to the value of the current column
during each iteration.
break
continue
return
handle.
eval (str)
error (message)
warning (message)
clear pattern
exist (str)
who, whos
whos var
find (a)
return indices of nonzero elements
sort (a)
order elements in each column of a
sum (a)
sum elements in columns of a
prod (a)
product of elements in columns of a
min (args)
find minimum values
max (args)
find maximum values
rem (x, y)
find remainder of x/y
reshape (a, m, n) reformat a to be m by n
diag (v, k)
create diagonal matrices
linspace (b, l, n) create vector of linearly-spaced elements
logspace (b, l, n) create vector of log-spaced elements
eye (n, m)
create n by m identity matrix
ones (n, m)
create n by m matrix of ones
zeros (n, m)
create n by m matrix of zeros
rand (n, m)
create n by m matrix of random values
Strings
strcmp (s, t)
strcat (s, t, ...)
regexp (str, pat)
regexprep (str, pat, rep)
compare strings
concatenate strings
strings matching regular expression
Match and replace sub-strings
Defining Functions
function [ret-list] function-name [ (arg-list) ]
function-body
endfunction
ret-list may be a single identifier or a comma-separated list of
identifiers delimited by square-brackets.
arg-list is a comma-separated list of identifiers and may be
empty.
Linear Algebra
chol (a)
det (a)
eig (a)
expm (a)
hess (a)
inverse (a)
norm (a, p)
pinv (a)
qr (a)
rank (a)
sprank (a)
schur (a)
svd (a)
syl (a, b, c)
Cholesky factorization
compute the determinant of a matrix
eigenvalues and eigenvectors
compute the exponential of a matrix
compute Hessenberg decomposition
invert a square matrix
compute the p-norm of a matrix
compute pseudoinverse of a
compute the QR factorization of a matrix
matrix rank
structural matrix rank
Schur decomposition of a matrix
singular value decomposition
solve the Sylvester equation
Signal Processing
fft (a)
ifft (a)
freqz (args)
filter (a, b, x)
conv (a, b)
hamming (n)
hanning (n)
Image Processing
colormap (map)
gray2ind (i, n)
image (img, zoom)
imagesc (img, zoom)
imread (file)
imshow (img, map)
imshow (i, n)
imshow (r, g, b)
imwrite (img, file)
ind2gray (img, map)
ind2rgb (img, map)
rgb2ind (r, g, b)
save a matrix to file
Polynomials
compan (p)
conv (a, b)
deconv (a, b)
poly (a)
polyderiv (p)
polyreduce (p)
polyval (p, x)
polyvalm (p, x)
roots (p)
residue (a, b)
companion matrix
convolution
deconvolve two vectors
create polynomial from a matrix
derivative of polynomial
integral of polynomial
value of polynomial at x
value of polynomial at x
polynomial roots
partial fraction expansion of ratio a/b
Statistics
corrcoef (x, y)
cov (x, y)
mean (a)
median (a)
std (a)
var (a)
correlation coefficient
covariance
mean value
median value
standard deviation
variance
Plotting Functions
set the current colormap
convert gray scale to Octave image
display an Octave image matrix
display scaled matrix as image
load an image file
display Octave image
display gray scale image
display RGB image
write images in various file formats
convert Octave image to gray scale
convert indexed image to RGB
convert RGB to Octave image
disp (var)
plot (args)
plot3 (args)
line (args)
patch (args)
semilogx (args)
semilogy (args)
loglog (args)
bar (args)
stairs (x, y)
stem (x, y)
hist (y, x)
contour (x, y, z)
title (string)
axis (limits)
xlabel (string)
ylabel (string)
zlabel (string)
text (x, y, str)
legend (string)
grid [on|off]
hold [on|off]
ishold
mesh (x, y, z)
meshgrid (x, y)
Edition 2.0 for Octave Version 3.0.0. Copyright 1996, 2007, John
W. Eaton ([email protected]). The author assumes no responsibility
for any errors on this card.
This card may be freely distributed under the terms of the GNU