Summary of Basic Matlab Functions

General Utility

help	help facility
demo	run demonstrations
who	list variables in memory
what	list M-files on disk
size	row and column dimensions
length	vector length
clear	clear workspace
computer	report computer type
^C	abort operation
quit	exit Matlab
exit	exit Matlab

Matrix  Operators

+	addition
-	subtraction
*	multiplication
/	right division
\	left division
^	power
Ô	conjugate transpose
.*	element multiplication
./	element right division
.^	element exponentiation
.Õ	nonconjugate transpose

Control Flow

if	conditional execution
elseif	used with if
else	used with if
end	terminate if, for, while
for	repeated execution
while	do while
break	abort for and while loops
return	return from functions
pause	pause until key press

Relational/Logical Operators

<	less than
<=	less than or equal
>	greater than
>=	greater than or equal
==	equal
~=	not equal
&	AND
|	OR
~	NOT

Special Characters

=	assignment statement
[	start matrix description
]	end matrix description
(	alter arithmetic precedence
)	used with (
,	add subscript or parameter
;	add row or suppress printing
%	start comment
:	used to generate vectors

Special Values

ans	result of last expression
eps	floating point precision
pi	3.14159292 ...
i,j	square root of -1
Inf	Infinity
NaN	Not-a-Number
clock	wall clock
date	date
flops	floating point operation count
nargin	# of function input arguments
nargout	# of function output arguments

Text and Strings

abs	convert string to ASCII values
blanks	string of n blanks
eval	evaluate string as commands
num2str	convert number to string
int2str	convert integer to string
setstr	mark matrix as string data
sprintf	print number to string
isstr	see if variable is a string
strcmp	compare string variables
hex2num	hexadecimal string to number

Plot Commands

plot	linear X-Y plot
polyline	line primitive
polymarker	marker primitive
text	text primitive
loglog	loglog X-Y plot
semilogx	log X - linear Y plot
semilogy	linear X - log Y plot
polar	polar plot
mesh	3-dimensional mesh surface
contour	contour plot
meshdom	domain for mesh plots
fplot	adaptive plot of function
bar	rectangular bar charts
polarbar	polar bar charts
stairs	stairstep graphs
errorbar	add errorbars
compass	phasor plot
rose	polar histogram
feather	row of phasors
quiver	phasor plot

Plot annotation

title	plot title
xlabel	x-axis label
grid	draw grid lines
text	user-placed text
gtext	mouse-positioned text
ginput	graphics input
clabel	label contours on plot

Graph scaling

axis	user-specified scaling
hold	overplot existing plot
shg	show graph window 
clg	clear graph window
subplot	partition graph window
sc2dc	screen coord. to data coord.
dc2sc	data coord. to screen coord.

Graph hardcopy

print	send graph to printer
prtsc	print graphics screen
meta	create graphics metafile

Command Window

clc	clear command window
home	home cursor
format	set display output format
disp	display matrix or text
fprintf	print formatted number
echo	enable command echoing

Programming and M-files

input	get numbers from keyboard
keyboard	call keyboard as M-file
error	display error message
function	define function
eval	interpret text in variables
feval	evaluate function in string
echo	enable command echoing
exist	check if variables exist
casesen	set case sensitivity
global	define global variables
startup	startup M-file
getenv	get environment string
menu	select item from text menu
etime	elapsed time

Disk files

chdir	change current directory
delete	delete file
diary	log session
dir	directory of files on disk
load	load variables from file
save	save variables on file
type	list function or file
what	show M-files on disk
fprintf	write to a file
pack	compact memory via save

Relational and Logical Functions

any	see if any item met condition
all	see if all items met condition
find	which items met condition
exist	check if variables exist
isnan	detect NaNs
finite	detect Infs (infinities)
isempty	detect empty matrices
isstr	detect string variables
strcmp	compare string variables

Trigonometric functions provided:

sine, cosine, tangent
arcsine, arccosine, arctangent, atan2
hyperbolic sine, cosine, tangent,
hyperbolic arcsine, arccosine, arctangent

Elementary  Functions

abs	absolute value
sqrt	square root
abs,angle	complex number length, angle
real,imag	real and imaginary parts
conj	complex conjugate
round,fix	round to closest integer, to 0
floor,ceil	round towards -Inf, +Inf
sign	signum function
rem	remainder or modulus
log, exp	natural logarithm, antilog
log10	log base 10
hex2dec	hexadecimal to decimal
dec2hex	decimal to hexadecimal

Special Functions

Bessel, gamma, error, inverse error
functions, Jacobian elliptic functions,
complete elliptic integral (first kind),
and rational approximation

Polynomials

poly	characteristic polynomial
roots	polynomial roots 
polyder	derivative of polynomial
polyval	polynomial evaluation
polyvalm	matrix polynomial evaluation
conv	polynomial multiplication
deconv	polynomial division
residue	partial-fraction expansion
polyfit	polynomial curve fitting

Matrix Manipulation

rot90	rotate matrix 90 degrees
fliplr	flip matrix left to right 
flipud	flip matrix up to down 
diag	extract or create diagonal
tril	lower triangular part
triu	upper triangular part
reshape	reshape matrix
.Õ	transposition
:	used for general rearrangement

Matrix Condition

cond	condition number in 2-norm
norm	1, 2, Frobenius and Inf norms
rank	rank of matrix
rcond	condition estimate

Special Matrices

compan	companion matrix
diag	diagonal matrix
eye	identity matrix
gallery	interesting matrices
linspace	linearly spaced vector
logspace	logarithmically spaced vector
magic	magic square
meshdom	domain for mesh plots
ones	matrix of all ones
rand	matrix of random elements
zeros	matrix of all zeros

also: Hadamard, Hankel, Hilbert, inverse
Hilbert, Pascal, Toeplitz and Vandermode
matrices

Decompositions and Factorizations

balance	balanced form
backsub	back substitution
cdf2rdf	complex-diagonal to real-diag
chol	Cholesky factorization
eig	eigenvalues and eigenvectors
hess	Hessenberg form
inv	inverse
lu	Gaussian elimination factors
lscov	least squares given covariance
nnls	nonnegative least-squares
null	null space
orth	orthogonalization
pinv	pseudoinverse
qr	orthogonal triangular factors
qz	QZ algorithm
rref	reduced row echelon form
rsf2csf	real-schur to complex-schur
schur	Schur decomposition
svd	singular value decomposition

Elementary Matrix Functions

expm	matrix exponential
logm	matrix logarithm
sqrtm	matrix square root
funm	arbitrary  matrix functions
poly	characteristic polynomial
det	determinant
trace	trace
kron	Kronecker tensor product

Interpolation

spline	cubic spline
table1	1-D table look-up
table2	2-D table look-up
mkpp	make piecewise polynomial
unmkpp	unmake piecewise polynomial
ppval	evaluate piecewise polynomial

Differential Eqns & Numerical Integration

ode23	2nd/3rd order Runge-Kutta
ode45	4th/5th Runge-Kutta-Fehlberg
quad	SimpsonÕs Rule integration
quad8	Newton Cotes integration

Nonlinear optimization and zero-finding

fmin	minimize f(x)
fmins	minimize f(x,y,z ...)
fzero	find zero of f(x)
fsolve	find zero of f(x,y,z ... )

Columnwise Data Analysis

max	maximum value by column
min	minimum value by column
mean	mean value
median	median value
std	standard deviation
sort	sort elements and indices
sum	sum elements by column
prod	product of elements
cumsum	cumulative sum
cumprod	cumulative product
diff	approximate derivatives
gradient	approximate gradient
hist	histogram
corrcoef	correlation coefficients
subspace	angle between two vectors
cov	covariance matrix
cplxpair	reorder into complex pairs

Signal Processing

conv	convolution
deconv	deconvolution
fft	fast Fourier transform
ifft	inverse of  fft
fft2	two-dimensional fft
ifft2	inverse of fft2
fftshift	shift quadrants of a matrix

Filter Analysis/Implementation

filter	direct filter implementation
unwrap	unwrap phase
ltitr	linear system time response
ltifr	system frequency response
