----------------------------------------------------------------------------------------- MATLAB's Main Categories of Functions ----------------------------------------------------------------------------------------- color Color control and lighting model functions. datafun Data analysis and Fourier transform functions. demos Demonstrations and samples. elfun Elementary math functions. elmat Elementary matrices and matrix manipulation. funfun Function functions -- nonlinear numerical methods. general General purpose commands. graphics General purpose graphics functions. iofun Low-level file I/O functions. lang Language constructs and debugging. matfun Matrix functions -- numerical linear algebra. ops Operators and special characters. plotxy Two dimensional graphics. plotxyz Three dimensional graphics. polyfun Polynomial and interpolation functions. sparfun Sparse matrix functions. specfun Specialized math functions. specmat Specialized matrices. sounds Sound processing functions. strfun Character string functions. -----------------------------------------------------------------------------------------The following pages contain tables of functions within each of these specific areas. If you execute help on one of the directory names listed on the left side of this table, MATLAB displays an online version of the tables within that area.
------------------------------------------------------------------------------- Managing Commands and Functions ------------------------------------------------------------------------------- demo Run demos. expo Run MATLAB EXPO demonstration program. help Online documentation. info Information about MATLAB and The MathWorks. lasterr Last error message generated. lookfor Keyword search through the help entries. path Control MATLAB's search path. subscribe Become a subscribing MATLAB user. type List M-file. ver Current MATLAB and toolbox versions. version Current MATLAB version number. what Directory listing of M-, MAT- and MEX-files. whatsnew Display README files for MATLAB and toolboxes. which Locate functions and files. -------------------------------------------------------------------------------
-------------------------------------------------------------------------------- Managing Variables and the Workspace -------------------------------------------------------------------------------- clear Clear variables and functions from memory. disp Display matrix or text. length Length of vector. load Retrieve variables from disk. pack Consolidate workspace memory. save Save workspace variables to disk. size Size of matrix. who List current variables. whos List current variables, long form. --------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------------- Working with Files and the Operating Environment -------------------------------------------------------------------------------------------------- cd Change current working directory. cedit Set command line editing parameters (UNIX only). delete Delete file. diary Save text of MATLAB session. dir Directory listing. getenv Get environment value. hostid MATLAB server host identification number. ls Directory listing. matlabroot Root directory of MATLAB installation. pwd Show current working directory. tempdir Name of system temporary directory. tempname Unique name for temporary file. terminal Set graphics terminal type. unix Execute operating system command; return result. ! Execute operating system command. --------------------------------------------------------------------------------------------------
----------------------------------------------------------------------- Controlling the Command Window ----------------------------------------------------------------------- clc Clear command window. echo Echo commands inside script files. format Set output format. home Send cursor home. more Control paged output in command window. -----------------------------------------------------------------------
-------------------------------------------------------------------------- Starting and Quitting from MATLAB -------------------------------------------------------------------------- matlabrc Master startup M-file. quit Terminate MATLAB. startup M-file executed when MATLAB is invoked. --------------------------------------------------------------------------
------------------------------------------------------------- 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. ./ Array division. : Colon. () Parentheses. [] Brackets. . Decimal point. .. Parent directory. ... 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 True if all elements of vector are true. any True if any element of vector is true. exist Check if variables or functions exist. find Find indices of nonzero elements. finite True for finite elements. isempty True for empty matrix. ishold True if hold is on. isieee True for IEEE floating-point arithmetic. isinf True for infinite elements. isletter True for alphabetic character. isnan True for Not-A-Number. isreal True if all matrix elements are real. issparse True for sparse matrix. isstr True for text string. -----------------------------------------------------------
------------------------------------------------------------------------ MATLAB as a Programming Language ------------------------------------------------------------------------ eval Execute string with MATLAB expression. feval Execute function specified by string. function Add new function. global Define global variable. nargchk Validate number of input arguments. ------------------------------------------------------------------------
------------------------------------------------------------------ Control Flow ------------------------------------------------------------------ break Terminate execution of loop. else Used with if. elseif Used with if. end Terminate the scope of for, while and if statements. error Display message and abort function. for Repeat statements a specific number of times. if Conditionally execute statements. return Return to invoking function. while Repeat statements an indefinite number of times. ------------------------------------------------------------------
--------------------------------------------------------------- Interactive Input --------------------------------------------------------------- input Prompt for user input. keyboard Invoke keyboard as if it were a script file. menu Generate menu of choices for user input. pause Wait for user response. ---------------------------------------------------------------
------------------------------------------ Debugging ------------------------------------------ dbclear Remove breakpoint. dbcont Resume execution. dbdown Change local workspace context. dbquit Quit debug mode. dbstack List who called whom. dbstatus List all breakpoints. dbstep Execute one or more lines. dbstop Set breakpoint. dbtype List M-file with line numbers. dbup Change local workspace context. mexdebug Enable MEX-file debugging. ------------------------------------------
---------------------------------------------------------------------- Elementary Matrices ---------------------------------------------------------------------- eye Identity matrix. gallery Test matrices - matrix condition and eigenvalues. linspace Linearly spaced vector. logspace Logarithmically spaced vector. meshgrid X and Y arrays for 3-D plots. ones Ones matrix. rand Uniformly distributed random numbers. randn Normally distributed random numbers. zeros Zeros matrix. : Regularly spaced vector. ----------------------------------------------------------------------
--------------------------------------------------------------------- Special Variables and Constants --------------------------------------------------------------------- ans Most recent answer. computer Computer type. eps Floating-point relative accuracy. flops Count of floating-point operations. i, j Imaginary unit. inf Infinity. NaN Not-a-Number. nargin Number of function input arguments. nargout Number of function output arguments. pi 3.1415926535897.... realmax Largest floating-point number. realmin Smallest floating-point number ---------------------------------------------------------------------
------------------------------------------ Time and Dates ------------------------------------------ clock Wall clock. cputime Elapsed CPU time. date Calendar. etime Elapsed time function. tic, toc Stopwatch timer functions. ------------------------------------------
------------------------------------------------------------------- Matrix Manipulation ------------------------------------------------------------------- diag Create or extract diagonals. fliplr Flip matrix in the left/right direction. flipud Flip matrix in the up/down direction. isreal True for matrix containing real elements only. reshape Change size. rot90 Rotate matrix 90 degrees. tril Extract lower triangular part. triu Extract upper triangular part. : Index into matrix, rearrange matrix. -------------------------------------------------------------------
---------------------------------------------------------------- Specialized Matrices ---------------------------------------------------------------- compan Companion matrix. hadamard Hadamard matrix. hankel Hankel matrix. hilb Hilbert matrix. invhilb Inverse Hilbert matrix. magic Magic square. pascal Pascal matrix. rosser Classic symmetric eigenvalue test problem. toeplitz Toeplitz matrix. vander Vandermonde matrix. wilkinson Wilkinson's eigenvalue test matrix. ----------------------------------------------------------------
--------------------------------------------------------- Elementary Math Functions --------------------------------------------------------- abs Absolute value. acos Inverse cosine. acosh Inverse hyperbolic cosine. acot Inverse cotangent. acoth Inverse hyperbolic cotangent. acsc Inverse cosecant. acsch Inverse hyperbolic cosecant. angle Phase angle. asec Inverse secant. asech Inverse hyperbolic secant. asin Inverse sine. asinh Inverse hyperbolic sine. atan Inverse tangent. atan2 Four quadrant inverse tangent. atanh Inverse hyperbolic tangent. ceil Round towards plus infinity. conj Complex conjugate. cos Cosine. cosh Hyperbolic cosine. cot Cotangent. coth Hyperbolic cotangent. csc Cosecant. csch Hyperbolic cosecant. exp Exponential. fix Round towards zero. floor Round towards minus infinity. gcd Greatest common divisor. imag Complex imaginary part. lcm Least common multiple. log Natural logarithm. log10 Common logarithm. real Complex real part. rem Remainder after division. round Round towards nearest integer. sec Secant. sech Hyperbolic secant. sign Signum function. sin Sine. sinh Hyperbolic sine. sqrt Square root. tan Tangent. tanh Hyperbolic tangent. ---------------------------------------------------------
------------------------------------------------------------------------- Specialized Math Functions ------------------------------------------------------------------------- bessel Bessel functions. besseli Modified Bessel functions of the first kind. besselj Bessel functions of the first kind. besselk Modified Bessel functions of the second kind. bessely Bessel functions of the second kind. beta Beta function. betainc Incomplete beta function. betaln Logarithm of beta function. ellipj Jacobi elliptic functions. ellipke Complete elliptic integral. erf Error function. erfc Complementary error function. erfcx Scaled complementary error function. erfinv Inverse error function. expint Exponential integral. gamma Gamma function. gammainc Incomplete gamma function. gammaln Logarithm of gamma function. legendre Associated Legendre functions. log2 Dissect floating point numbers. pow2 Scale floating point numbers. rat Rational approximation. rats Rational output. -------------------------------------------------------------------------
---------------------------------------------------------------- Matrix Analysis ---------------------------------------------------------------- cond Matrix condition number. det Determinant. etree Elimination tree of a matrix. norm Matrix or vector norm. null Null space. orth Orthogonalization. rcond LINPACK reciprocal condition estimator. rank Number of linearly independent rows or columns. rref Reduced row echelon form. subspace Angle between two subspaces. trace Sum of diagonal elements. ----------------------------------------------------------------
-------------------------------------------------------------------- Linear Equations -------------------------------------------------------------------- chol Cholesky factorization. inv Matrix inverse. lscov Least squares in the presence of known covariance. lu Factors from Gaussian elimination. nnls Non-negative least-squares. pinv Pseudoinverse. qr Orthogonal-triangular decomposition. \ and / Linear equation solution. --------------------------------------------------------------------
----------------------------------------------------------------------------------- Eigenvalues and Singular Values ----------------------------------------------------------------------------------- balance Diagonal scaling to improve eigenvalue accuracy. cdf2rdf Complex diagonal form to real block diagonal form. eig Eigenvalues and eigenvectors. hess Hessenberg form. poly Characteristic polynomial. qz Generalized eigenvalues. rsf2csf Real block diagonal form to complex diagonal form. schur Schur decomposition. svd Singular value decomposition. -----------------------------------------------------------------------------------
--------------------------------------------------- Matrix Functions --------------------------------------------------- expm Matrix exponential. funm Evaluate general matrix function. logm Matrix logarithm. sqrtm Matrix square root. ---------------------------------------------------
---------------------------------------------------------- Low Level Functions ---------------------------------------------------------- qrdelete Delete columns from QR factorization. qrinsert Insert columns into QR factorization. ----------------------------------------------------------
----------------------------------------------------------------- Basic Operations ----------------------------------------------------------------- cumprod Cumulative product of elements. cumsum Cumulative sum of elements. max Largest component. mean Average or mean value. median Median value. min Smallest component. prod Product of elements. sort Sort in ascending order. std Standard deviation. sum Sum of elements. trapz Numerical integration using trapezoidal method. -----------------------------------------------------------------
------------------------------------------------------------------- Finite Differences ------------------------------------------------------------------- del2 Five-point discrete Laplacian. diff Difference function and approximate derivative. gradient Approximate 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 One-dimensional digital filter. filter2 Two-dimensional digital filter. ---------------------------------------------------------------------
----------------------------------------------------------------------- Fourier Transforms ----------------------------------------------------------------------- abs Magnitude. angle Phase angle. cplxpair Sort numbers into complex conjugate pairs. fft Discrete Fourier transform. fft2 Two-dimensional discrete Fourier transform. fftshift Move zeroth lag to center of spectrum. ifft Inverse discrete Fourier transform. ifft2 Two-dimensional inverse discrete Fourier transform. nextpow2 Next higher power of 2. unwrap Remove phase angle jumps across 360\xa1 boundaries. -----------------------------------------------------------------------
--------------------------------------- Vector Functions --------------------------------------- cross Vector cross product. dot Vector dot product. ---------------------------------------
------------------------------------------------------- Polynomials ------------------------------------------------------- conv Multiply polynomials. deconv Divide polynomials. poly Construct polynomial with specified roots. polyder Differentiate polynomial. polyeig Solve polynomial eigenvalue problem. polyfit Fit polynomial to data. polyval Evaluate polynomial. polyvalm Evaluate polynomial with matrix argument. residue Partial-fraction expansion (residues). roots Find polynomial roots. -------------------------------------------------------
--------------------------------------------------------------------- Data Interpolation --------------------------------------------------------------------- griddata Data gridding. interp1 One-dimensional interpolation (1-D table lookup). interp2 Two-dimensional interpolation (2-D table lookup). interpft One-dimensional interpolation using FFT method. ---------------------------------------------------------------------
--------------------------------------------------------------------------------------------------- Function Functions - Nonlinear Numerical Methods --------------------------------------------------------------------------------------------------- fmin Minimize function of one variable. fmins Minimize function of several variables. fplot Plot function. fzero Find zero of function of one variable. ode23 Solve differential equations, low order method. ode45 Solve differential equations, high order method. quad Numerically evaluate integral, low order method. quad8 Numerically evaluate integral, high order method. ---------------------------------------------------------------------------------------------------
---------------------------------------------------------------- Elementary Sparse Matrices ---------------------------------------------------------------- spdiags Sparse matrix formed from diagonals. speye Sparse identity matrix. sprandn Sparse random matrix. sprandsym Sparse symmetric random matrix. ----------------------------------------------------------------
--------------------------------------------------------------------------- Full to Sparse Conversion --------------------------------------------------------------------------- find Find indices of nonzero entries. full Convert sparse matrix to full matrix. sparse Create sparse matrix from nonzeros and indices. spconvert Convert from sparse matrix external format. ---------------------------------------------------------------------------
------------------------------------------------------------------------------------------------- Working with Nonzero Entries of Sparse Matrices ------------------------------------------------------------------------------------------------- issparse True if matrix is sparse. nnz Number of nonzero entries. nonzeros Nonzero entries. nzmax Amount of storage allocated for nonzero entries. spalloc Allocate memory for nonzero entries. spfun Apply function to nonzero entries. spones Replace nonzero entries with ones. -------------------------------------------------------------------------------------------------
-------------------------------------------------------------- Visualizing Sparse Matrices -------------------------------------------------------------- gplot Plot graph, as in "graph theory." spy Visualize sparsity structure. --------------------------------------------------------------
------------------------------------------------------------ Reordering Algorithms ------------------------------------------------------------ colmmd Column minimum degree. colperm Order columns based on nonzero count. dmperm Dulmage-Mendelsohn decomposition. randperm Random permutation vector. symmmd Symmetric minimum degree. symrcm Reverse Cuthill-McKee ordering. ------------------------------------------------------------
------------------------------------------------------------ Norm, Condition Number, and Rank ------------------------------------------------------------ condest Estimate 1-norm condition. normest Estimate 2-norm. sprank Structural rank. ------------------------------------------------------------
--------------------------------------------------------- Miscellaneous --------------------------------------------------------- spaugment Form least squares augmented system. spparms Set parameters for sparse matrix routines. symbfact Symbolic factorization analysis. ---------------------------------------------------------