MATLAB Functions Help Desk

Command Summary


This chapter lists MATLAB commands by functional area.

General Purpose Commands

Managing Commands and Functions
addpath Add directories to MATLAB's search path
doc Load hypertext documentation
help Online help for MATLAB functions and M-files
lasterr Last error message
lookfor Keyword search through all help entries
path Control MATLAB's directory search path
profile Measure and display M-file execution profiles
rmpath Remove directories from MATLAB's search path
type List file
version MATLAB version number
what Directory listing of M-files, MAT-files, and MEX-files
whatsnew Display README files for MATLAB and toolboxes
which Locate functions and files
Managing Variables and the Workspace
clear Remove items from memory
disp Display text or array
length Length of vector
load Retrieve variables from disk
pack Consolidate workspace memory
save Save workspace variables on disk
size Array dimensions
who, whos List directory of variables in memory
Controlling the Command Window
echo Echo M-files during execution
format Control the output display format
more Control paged output for the command window
Working with Files and the Operating Environment
applescript Load a compiled AppleScript from a file and execute it
cd Change working directory
delete Delete files and graphics objects
diary Save session in a disk file
dir Directory listing
edit Edit an M-file
fullfile Build full filename from parts
inmem Functions in memory
matlabroot Root directory of MATLAB installation
tempdir Return the name of the system's temporary directory
tempname Unique name for temporary file
! Execute operating system command
Starting and Quitting MATLAB
matlabrc MATLAB startup M-file
quit Terminate MATLAB
startup MATLAB startup M-file

Operators and Special Characters

+ Plus
- Minus
* Matrix multiplication
.* Array multiplication
^ Matrix power
.^ Array power
kron Kronecker tensor product
\ Backslash or left division
/ Slash or right division
./ and .\ Array division, right and left
: Colon
( ) Parentheses
[ ] Brackets
{} Curly braces
. Decimal point
... Continuation
, Comma
; Semicolon
% Comment
! Exclamation point
' Transpose and quote
.' Nonconjugated transpose
= Assignment
== Equality
< > Relational operators
& Logical and
| Logical or
~ Logical not
xor Logical exclusive or

Logical Functions

all Test to determine if all elements are nonzero
any Test for any nonzeros
exist Check if a variable or file exists
find Find indices and values of nonzero elements
is* Detect state
*isa Detect an object of a given class
logical Convert numeric values to logical

Language Constructs and Debugging

MATLAB as a Programming Language
builtin Execute builtin function from overloaded method
eval Interpret strings containing MATLAB expressions
feval Function evaluation
function Function M-files
global Define global variables
nargchk Check number of input arguments
script Script M-files
Control Flow
break Break out of flow control structures
case Case switch
else Conditionally execute statements
elseif Conditionally execute statements
end Terminate for, while, switch, and if statements or indicate last index
error Display error messages
for Repeat statements a specific number of times
if Conditionally execute statements
otherwise Default part of switch statement
return Return to the invoking function
switch Switch among several cases based on expression
warning Display warning message
while Repeat statements an indefinite number of times
Interactive Input
input Request user input
keyboard Invoke the keyboard in an M-file
menu Generate a menu of choices for user input
pause Halt execution temporarily
Object-Oriented Programming
class Create object or return class of object
double Convert to double precision
inferiorto Inferior class relationship
inline Construct an inline object
isa Detect an object of a given class
superiorto Superior class relationship
uint8 Convert to unsigned 8-bit integer
Debugging
dbclear Clear breakpoints
dbcont Resume execution
dbdown Change local workspace context
dbmex Enable MEX-file debugging
dbquit Quit debug mode
dbstack Display function call stack
dbstatus List all breakpoints
dbstep Execute one or more lines from a breakpoint
dbstop Set breakpoints in an M-file function
dbtype List M-file with line numbers
dbup Change local workspace context

Elementary Matrices and Matrix Manipulation

Elementary Matrices and Arrays
eye Identity matrix
linspace Generate linearly spaced vectors
logspace Generate logarithmically spaced vectors
ones Create an array of all ones
rand Uniformly distributed random numbers and arrays
randn Normally distributed random numbers and arrays
zeros Create an array of all zeros
: (colon) Regularly spaced vector
Special Variables and Constants
ans The most recent answer
computer Identify the computer on which MATLAB is running
eps Floating-point relative accuracy
flops Count floating-point operations
i Imaginary unit
Inf Infinity
inputname Input argument name
j Imaginary unit
NaN Not-a-Number
nargin, nargout Number of function arguments
pi Ratio of a circle's circumference to its diameter,
realmax Largest positive floating-point number
realmin Smallest positive floating-point number
varargin, varargout varargin, varargout
Time and Dates
calendar Calendar
clock Current time as a date vector
cputime Elapsed CPU time
date Current date string
datenum Serial date number
datestr Date string format
datevec Date components
eomday End of month
etime Elapsed time
now Current date and time
tic, toc Stopwatch timer
weekday Day of the week
Matrix Manipulation
cat Concatenate arrays
diag Diagonal matrices and diagonals of a matrix
fliplr Flip matrices left-right
flipud Flip matrices up-down
repmat Replicate and tile an array
reshape Reshape array
rot90 Rotate matrix 90 degrees
tril Lower triangular part of a matrix
triu Upper triangular part of a matrix
: (colon) Index into array, rearrange array

Specialized Matrices

compan Companion matrix
gallery Test matrices
hadamard Hadamard matrix
hankel Hankel matrix
hilb Hilbert matrix
invhilb Inverse of the Hilbert matrix
magic Magic square
pascal Pascal matrix
toeplitz Toeplitz matrix
wilkinson Wilkinson's eigenvalue test matrix

Elementary Math Functions

abs Absolute value and complex magnitude
acos, acosh Inverse cosine and inverse hyperbolic cosine
acot, acoth Inverse cotangent and inverse hyperbolic cotangent
acsc, acsch Inverse cosecant and inverse hyperbolic cosecant
angle angle Phase angle
asec, asech Inverse secant and inverse hyperbolic secant
asin, asinh Inverse sine and inverse hyperbolic sine
atan, atanh Inverse tangent and inverse hyperbolic tangent
atan2 Four-quadrant inverse tangent
ceil Round toward infinity
conj Complex conjugate
cos, cosh Cosine and hyperbolic cosine
cot, coth Cotangent and hyperbolic cotangent
csc, csch Cosecant and hyperbolic cosecant
exp Exponential
fix Round towards zero
floor Round towards minus infinity
gcd Greatest common divisor
imag Imaginary part of a complex number
lcm Least common multiple
log Natural logarithm
log2 Base 2 logarithm and dissect floating-point numbers into exponent and
log10 Common (base 10) logarithm
mod Modulus (signed remainder after division)
real Real part of complex number
rem Remainder after division
round Round to nearest integer
sec, sech Secant and hyperbolic secant
sign Signum function
sin, sinh Sine and hyperbolic sine
sqrt Square root
tan, tanh Tangent and hyperbolic tangent

Specialized Math Functions

airy Airy functions
besselh Bessel functions of the third kind (Hankel functions)
besseli, besselk
besselj, bessely
beta, betainc, betaln beta, betainc, betaln
ellipj Jacobi elliptic functions
ellipke Complete elliptic integrals of the first and second kind
erf, erfc, erfcx, erfinv erf, erfc, erfcx, erfinv
expint Exponential integral
gamma, gammainc, gammaln gamma, gammainc, gammaln
legendre Associated Legendre functions
pow2 Base 2 power and scale floating-point numbers
rat, rats Rational fraction approximation

Coordinate System Conversion

cart2pol Transform Cartesian coordinates to polar or cylindrical
cart2sph Transform Cartesian coordinates to spherical
pol2cart Transform polar or cylindrical coordinates to Cartesian
sph2cart Transform spherical coordinates to Cartesian

Matrix Functions - Numerical Linear Algebra

Matrix Analysis
cond Condition number with respect to inversion
condeig Condition number with respect to eigenvalues
det Matrix determinant
norm Vector and matrix norms
null Null space of a matrix
orth Range space of a matrix
rank Rank of a matrix
rcond Matrix reciprocal condition number estimate
rref, rrefmovie rref, rrefmovie
subspace Angle between two subspaces
trace Sum of diagonal elements
Linear Equations
\ / Linear equation solution
chol Cholesky factorization
inv Matrix inverse
lscov Least squares solution in the presence of known covariance
lu LU matrix factorization
nnls Nonnegative least squares
pinv Moore-Penrose pseudoinverse of a matrix
qr Orthogonal-triangular decomposition
Eigenvalues and Singular Values
balance Improve accuracy of computed eigenvalues
cdf2rdf Convert complex diagonal form to real block diagonal form
eig Eigenvalues and eigenvectors
hess Hessenberg form of a matrix
poly Polynomial with specified roots
qz QZ factorization for generalized eigenvalues
rsf2csf Convert real Schur form to complex Schur form
schur Schur decomposition
svd Singular value decomposition
Matrix Functions
expm Matrix exponential
funm Evaluate functions of a matrix
logm Matrix logarithm
sqrtm Matrix square root
Low Level Functions
qrdelete Delete column from QR factorization
qrinsert Insert column in QR factorization

Data Analysis and Fourier Transform Functions

Basic Operations
convhull Convex hull
cumprod Cumulative product
cumsum Cumulative sum
cumtrapz Cumulative trapezoidal numerical integration
delaunay Delaunay triangulation
dsearch Search for nearest point
factor Prime factors
inpolygon Detect points inside a polygonal region
max Maximum elements of an array
mean Average or mean value of arrays
median Median value of arrays
min Minimum elements of an array
perms All possible permutations
polyarea Area of polygon
primes Generate list of prime numbers
prod Product of array elements
sort Sort elements in ascending order
sortrows Sort rows in ascending order
std Standard deviation
sum Sum of array elements
trapz Trapezoidal numerical integration
tsearch Search for enclosing Delaunay triangle
voronoi Voronoi diagram
Finite Differences
del2 Discrete Laplacian
diff Differences and approximate derivatives
gradient Numerical gradient
Correlation
corrcoef Correlation coefficients
cov Covariance matrix
Filtering and Convolution
conv Convolution and polynomial multiplication
conv2 Two-dimensional convolution
deconv Deconvolution and polynomial division
filter Filter data with an infinite impulse response (IIR) or finite impulse response
filter2 Two-dimensional digital filtering
Fourier Transforms
abs Absolute value and complex magnitude
angle Phase angle
cplxpair Sort complex numbers into complex conjugate pairs
fft One-dimensional fast Fourier transform
fft2 Two-dimensional fast Fourier transform
fftshift Move zero'th lag to center of spectrum.
ifft Inverse one-dimensional fast Fourier transform
ifft2 Inverse two-dimensional fast Fourier transform
nextpow2 Next power of two
unwrap Correct phase angles
Vector Functions
cross Vector cross product
intersect Set intersection of two vectors
ismember Detect members of a set
setdiff Return the set difference of two vectors
setxor Set exclusive-or of two vectors
union Set union of two vectors
unique Unique elements of a vector

Polynomial and Interpolation Functions

Polynomials
conv Convolution and polynomial multiplication
deconv Deconvolution and polynomial division
poly Polynomial with specified roots
polyder Polynomial derivative
polyeig Polynomial eigenvalue problem
polyfit Polynomial curve fitting
polyval Polynomial evaluation
polyvalm Matrix polynomial evaluation
residue Convert between partial fraction expansion and polynomial coefficients
roots Polynomial roots
Data Interpolation
griddata Data gridding
interp1 One-dimensional data interpolation (table lookup)
interp2 Two-dimensional data interpolation (table lookup)
interp3 Three-dimensional data interpolation (table lookup)
interpft One-dimensional interpolation using the FFT method
interpn Multidimensional data interpolation (table lookup)
meshgrid Generate X and Y matrices for three-dimensional plots
ndgrid Generate arrays for multidimensional functions and interpolation
spline Cubic spline interpolation

Function Functions - Nonlinear Numerical Methods

dblquad Numerical double integration
fmin Minimize a function of one variable
fmins Minimize a function of several variables
fzero Zero of a function of one variable
ode45, ode23, ode113, ode15s, ode23s ode45, ode23, ode113, ode15s, ode23s
odefile Define a differential equation problem for ODE solvers
odeget Extract properties from options structure created with odeset
odeset Create or alter options structure for input to ODE solvers
quad, quad8 Numerical evaluation of integrals

Sparse Matrix Functions

Elementary Sparse Matrices
spdiags Extract and create sparse band and diagonal matrices
speye Sparse identity matrix
sprand Sparse uniformly distributed random matrix
sprandn Sparse normally distributed random matrix
sprandsym Sparse symmetric random matrix
Full to Sparse Conversion
find Find indices and values of nonzero elements
full Convert sparse matrix to full matrix
sparse Create sparse matrix
spconvert Import matrix from sparse matrix external format
Working with Nonzero Entries of Sparse Matrices
nnz Number of nonzero matrix elements
nonzeros Nonzero matrix elements
nzmax Amount of storage allocated for nonzero matrix elements
spalloc Allocate space for sparse matrix
spfun Apply function to nonzero sparse matrix elements
spones Replace nonzero sparse matrix elements with ones
Visualizing Sparse Matrices
spy Visualize sparsity pattern
Reordering Algorithms
colmmd Sparse column minimum degree permutation
colperm Sparse column permutation based on nonzero count
dmperm Dulmage-Mendelsohn decomposition
randperm Random permutation
symmmd Sparse symmetric minimum degree ordering
symrcm Sparse reverse Cuthill-McKee ordering
Norm, Condition Number, and Rank
condest 1-norm matrix condition number estimate
normest 2-norm estimate
Sparse Systems of Linear Equations
bicg BiConjugate Gradients method
bicgstab BiConjugate Gradients Stabilized method
cgs Conjugate Gradients Squared method
cholinc Incomplete Cholesky factorizations
gmres Generalized Minimum Residual method (with restarts)
luinc Incomplete LU matrix factorizations
pcg Preconditioned Conjugate Gradients method
qmr Quasi-Minimal Residual method
Sparse Eigenvalues and Singular Values
eigs Find a few eigenvalues and eigenvectors
svds A few singular values
Miscellaneous
spparms Set parameters for sparse matrix routines

Sound Processing Functions

General Sound Functions
sound Convert vector into sound
SPARCstation-specific Sound Functions
auread Read NeXT/SUN (.au) sound file
auwrite Write NeXT/SUN (.au) sound file
.WAV Sound Functions
wavread Read Microsoft WAVE (.wav) sound file
wavwrite Write Microsoft WAVE (.wav) sound file

Character String Functions

General
abs Absolute value and complex magnitude
eval Interpret strings containing MATLAB expressions
real Real part of complex number
strings MATLAB string handling
String Manipulation
deblank Strip trailing blanks from the end of a string
findstr Find one string within another
lower Convert string to lower case
strcat String concatenation
strcmp Compare strings
strjust Justify a character array
strmatch Find possible matches for a string
strncmp Compare the first n characters of two strings
strrep String search and replace
strtok First token in string
strvcat Vertical concatenation of strings
upper Convert string to upper case
String to Number Conversion
char Create character array (string)
int2str Integer to string conversion
mat2str Convert a matrix into a string
num2str Number to string conversion
sprintf Write formatted data to a string
sscanf Read string under format control
str2num String to number conversion
Radix Conversion
bin2dec Binary to decimal number conversion
dec2bin Decimal to binary number conversion
dec2hex Decimal to hexadecimal number conversion
hex2dec IEEE hexadecimal to decimal number conversion
hex2num Hexadecimal to double number conversion

Low-Level File I/O Functions

File Opening and Closing
fclose Close one or more open files
fopen Open a file or obtain information about open files
Unformatted I/O
fread Read binary data from file
fwrite Write binary data to a file
Formatted I/O
fgetl Return the next line of a file as a string without line terminator(s)
fgets Return the next line of a file as a string with line terminator(s)
fprintf Write formatted data to file
fscanf Read formatted data from file
File Positioning
feof Test for end-of-file
ferror Query MATLAB about errors in file input or output
frewind Rewind an open file
fseek Set file position indicator
ftell Get file position indicator
String Conversion
sprintf Write formatted data to a string
sscanf Read string under format control
Specialized File I/O
dlmread Read an ASCII delimited file into a matrix
dlmwrite Write a matrix to an ASCII delimited file
imfinfo Return information about a graphics file
imread Read image from graphics file
imwrite Write an image to a graphics file
wk1read Read a Lotus123 WK1 spreadsheet file into a matrix
wk1write Write a matrix to a Lotus123 WK1 spreadsheet file

Bitwise Functions

bitand Bit-wise AND
bitcmp Complement bits
bitor Bit-wise OR
bitmax Maximum floating-point integer
bitset Set bit
bitshift Bit-wise shift
bitget Get bit
bitxor Bit-wise XOR

Structure Functions

fieldnames Field names of a structure
getfield Get field of structure array
rmfield Remove structure fields
setfield Set field of structure array
struct Create structure array
struct2cell Structure to cell array conversion

Object Functions

class Create object or return class of object
isa Detect an object of a given class

Cell Array Functions

cell Create cell array
cellstr Create cell array of strings from character array
cell2struct Cell array to structure array conversion
celldisp Display cell array contents.
cellplot Graphically display the structure of cell arrays
num2cell Convert a numeric array into a cell array

Multidimensional Array Functions

cat Concatenate arrays
flipdim Flip array along a specified dimension
ind2sub Subscripts from linear index
ipermute Inverse permute the dimensions of a multidimensional array
ndgrid Generate arrays for multidimensional functions and interpolation
ndims Number of array dimensions
permute Rearrange the dimensions of a multidimensional array
reshape Reshape array
shiftdim Shift dimensions
squeeze Remove singleton dimensions
sub2ind Single index from subscripts

Graphics Functions
Color Operations and Lighting
brighten Brighten or darken color map
caxis Pseudocolor axis scaling
colorbar Display color bar (color scale)
colordef Set up color defaults
colormap Set the color look-up table
contrast Gray color map to enhance image contrast
graymon Graphics figure defaults set for gray-scale monitor
hsv2rgb Hue-saturation-value to red-green-blue conversion
lighting Lighting mode
material Material reflectance mode
rgb2hsv RGB to HSVconversion
rgbplot Plot color map
shading Color shading mode
spinmap Spin the colormap
surfnorm 3-D surface normals
whitebg Change axes background color for plots
Basic Plots and Graphs
bar Vertical bar chart
barh Horizontal bar chart
hist Plot histograms
hold Hold current graph
loglog Plot using log-log scales
pie Pie plot
plot Plot vectors or matrices.
polar Polar coordinate plot
semilogx Semi-log scale plot
semilogy Semi-log scale plot
subplot Create axes in tiled positions
Hardcopy/File Output
orient Hardcopy paper orientation
print Print graph or save graph to file
printopt Configure local printer defaults
Surface, Mesh, and Contour Plots
contour Contour (level curves) plot.
contourc Contour computation
contourf Filled contour plot
hidden Mesh hidden line removal mode
meshc Combination mesh/contourplot
mesh 3-D mesh with reference plane
surf 3-D shaded surface graph
surface Create surface low-level objects
surfc Combination surf/contourplot
surfl 3-D shaded surface with lighting
trimesh Triangular mesh plot
trisurf Triangular surface plot
Domain Generation for Function Visualization
griddata Data gridding and surface fitting
meshgrid Generation of X and Y arrays for 3-D plots
Specialized Plotting
area Area plot
box Axis box for 2-D and 3-D plots
comet Comet plot
compass Compass plot
errorbar Plot graph with error bars
ezplot Easy to use function plotter
feather Feather plot
fill Draw filled 2-D polygons
fplot Plot a function
pareto Pareto chart
pie3 3-D Pie plot
plotmatrix Scatter plot matrix
pcolor Pseudocolor (checkerboard) plot
rose Plot rose or angle histogram
quiver Quiver (or velocity) plot
ribbon Ribbon plot
stairs Stairstep graph
stem Plot discrete sequence data
Three-Dimensional Plotting
bar3 Vertical 3-D bar chart
bar3h Horizontal 3-D bar chart
comet3 3-D Comet plot
cylinder Generate cylinder
fill3 Draw filled 3-D polygons in 3-space
plot3 Plot lines and points in 3-D space
quiver3 3-D Quiver (or velocity) plot
slice Volumetric slice plot
sphere Generate sphere
stem3 Plot discrete surface data
view 3-D graph viewpoint specification.
viewmtx Generate view transformation matrices
waterfall Waterfall plot
Plot Annotation and Grids
clabel Add contour labels to a contour plot
datetick Date formatted tick labels
grid Grid lines for 2-D and 3-D plots
gtext Place text on a 2-D graph using a mouse
legend Graph legend for lines and patches
plotyy Plot graphs with Y tick labels on the left and right
title Titles for 2-D and 3-D plots
xlabel X-axis labels for 2-D and 3-D plots
ylabel Y-axis labels for 2-D and 3-D plots
zlabel Z-axis labels for 3-D plots
Handle Graphics, General
copyobj Make a copy of a graphics object and its children
findobj Find objects with specified property values
gcbo Return object whose callback is currently executing
gco Return handle of current object
get Get object properties
rotate Rotate objects about specified origin and direction
ishandle True for graphics objects
set Set object properties
Handle Graphics, Object Creation
axes Create axis at arbitrary positions
figure Create Figures (graph windows)
image Display image (create image object)
light Create light object
line Create line low-level objects
patch Create patch low-level objects
text Add text to the current plot
Handle Graphics, Figure Windows
capture Screen capture of the current figure
clc Clear figure window
clf Clear Figure
close Close specified window
gcf Get current figure handle
newplot Graphics M-file preamble for NextPlot property
refresh Refresh figure
Handle Graphics, Axes
axis Plot axis scaling and appearance
cla Clear axis
gca Get current axis handle
Object Manipulation
reset Reset axis or figure
rotate3d Interactively rotate the view of a 3-D plot
selectmoveresize Interactively select, move, or resize objects
Graphical User Interface Creation
dialog Create a dialog box
errordlg Create error dialog box
helpdlg Display help dialog box
inputdlg Create input dialog
menu Generate a menu of choices for user input
msgbox Create message dialog box
questdlg Create question dialog box
textwrap Return wrapped string matrix for given UI Control
uicontrol Create user interface control
uigetfile Display dialog box to retrieve name of file for reading
uimenu Create user interface menu
uiputfile Display dialog box to retrieve name of file for writing
uiresume Used with uiwait, controls program execution
uisetcolor Interactively set a ColorSpec via a dialog box
uisetfont Interactively set a font by displaying a dialog box
uiwait Used with uiresume, controls program execution
waitbar Display wait bar
waitforbuttonpress Wait for key/buttonpress over figure
warndlg Create warning dialog box
Interactive User Input
ginput Graphical input from a mouse or cursor
zoom Zoom in and out on a 2-D plot
Region of Interest
dragrect Drag XOR rectangles with mouse
drawnow Complete any pending drawing
rbbox Rubberband box
Micellaneous Graphics Commands
convhull Convex hull
delaunay Delaunay triangulation
dsearch Search Delaunay triangulation for nearest point
inpolygon True for points inside a polygonal region
polyarea Area of polygon
tsearch Search for enclosing Delaunay triangle
voronoi Voronoi diagram



[ Previous | Help Desk | Next ]