1 Functions By Category
Category Description
“Sparse Matrices” Elementary sparse matrices, operations,
reordering algorithms, linear algebra, iterative
methods, tree operations
“Math Constants” Pi, imaginary unit, infinity, Not-a-Number,
largest and smallest positive floating point
numbers, floating point relative accuracy
Arrays and Matrices
• “Basic Information”
• “Operators”
• “Operations and Manipulation”
• “Elementary Matrices and Arrays”
• “Specialized Matrices”
Basic Information
disp Display array
display Display array
isempty True for empty matrix
isequal True if arrays are identical
islogical True for logical array
isnumeric True for numeric arrays
issparse True for sparse matrix
length Length of vector
ndims Number of dimensions
numel Number of elements
size Size of matrix
Operators
+ Addition
+ Unary plus
- Subtraction
- Unary minus
* Matrix multiplication
^ Matrix power
\ Backslash or left matrix divide
1-8
Mathematics
/ Slash or right matrix divide
' Transpose
.' Nonconjugated transpose
.* Array multiplication (element-wise)
.^ Array power (element-wise)
.\ Left array divide (element-wise)
./ Right array divide (element-wise)
Operations and Manipulation
: (colon) Index into array, rearrange array
blkdiag Block diagonal concatenation
cat Concatenate arrays
cross Vector cross product
cumprod Cumulative product
cumsum Cumulative sum
diag Diagonal matrices and diagonals of matrix
dot Vector dot product
end Last index
find Find indices of nonzero elements
fliplr Flip matrices left-right
flipud Flip matrices up-down
flipdim Flip matrix along specified dimension
horzcat Horizontal concatenation
ind2sub Multiple subscripts from linear index
ipermute Inverse permute dimensions of multidimensional array
kron Kronecker tensor product
max Maximum elements of array
min Minimum elements of array
permute Rearrange dimensions of multidimensional array
prod Product of array elements
repmat Replicate and tile array
reshape Reshape array
rot90 Rotate matrix 90 degrees
sort Sort elements in ascending order
sortrows Sort rows in ascending order
sum Sum of array elements
sqrtm Matrix square root
sub2ind Linear index from multiple subscripts
tril Lower triangular part of matrix
triu Upper triangular part of matrix
vertcat Vertical concatenation
1-9
1 Functions By Category
See also “Linear Algebra” for other matrix operations.
See also “Elementary Math” for other array operations.
Elementary Matrices and Arrays
: (colon) Regularly spaced vector
blkdiag Construct block diagonal matrix from input arguments
diag Diagonal matrices and diagonals of matrix
eye Identity matrix
freqspace Frequency spacing for frequency response
linspace Generate linearly spaced vectors
logspace Generate logarithmically spaced vectors
meshgrid Generate X and Y matrices for three-dimensional plots
ndgrid Arrays for multidimensional functions and interpolation
ones Create array of all ones
rand Uniformly distributed random numbers and arrays
randn Normally distributed random numbers and arrays
repmat Replicate and tile array
zeros Create array of all zeros
Specialized Matrices
compan Companion matrix
gallery Test matrices
hadamard Hadamard matrix
hankel Hankel matrix
hilb Hilbert matrix
invhilb Inverse of 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
Linear Algebra
• “Matrix Analysis”
• “Linear Equations”
• “Eigenvalues and Singular Values”
• “Matrix Logarithms and Exponentials”
• “Factorization”
1-10
Mathematics
Matrix Analysis
cond Condition number with respect to inversion
condeig Condition number with respect to eigenvalues
det Determinant
norm Matrix or vector norm
normest Estimate matrix 2-norm
null Null space
orth Orthogonalization
rank Matrix rank
rcond Matrix reciprocal condition number estimate
rref Reduced row echelon form
subspace Angle between two subspaces
trace Sum of diagonal elements
Linear Equations
\ and / Linear equation solution
chol Cholesky factorization
cholinc Incomplete Cholesky factorization
cond Condition number with respect to inversion
condest 1-norm condition number estimate
funm Evaluate general matrix function
inv Matrix inverse
lscov Least squares solution in presence of known covariance
lsqnonneg Nonnegative least squares
lu LU matrix factorization
luinc Incomplete LU factorization
pinv Moore-Penrose pseudoinverse of matrix
qr Orthogonal-triangular decomposition
rcond Matrix reciprocal condition number estimate
Eigenvalues and Singular Values
balance Improve accuracy of computed eigenvalues
cdf2rdf Convert complex diagonal form to real block diagonal form
condeig Condition number with respect to eigenvalues
eig Eigenvalues and eigenvectors
eigs Eigenvalues and eigenvectors of sparse matrix
gsvd Generalized singular value decomposition
hess Hessenberg form of matrix
poly Polynomial with specified roots
polyeig Polynomial eigenvalue problem
qz QZ factorization for generalized eigenvalues
rsf2csf Convert real Schur form to complex Schur form
1-11
1 Functions By Category
schur Schur decomposition
svd Singular value decomposition
svds Singular values and vectors of sparse matrix
Matrix Logarithms and Exponentials
expm Matrix exponential
logm Matrix logarithm
sqrtm Matrix square root
Factorization
balance Diagonal scaling to improve eigenvalue accuracy
cdf2rdf Complex diagonal form to real block diagonal form
chol Cholesky factorization
cholinc Incomplete Cholesky factorization
cholupdate Rank 1 update to Cholesky factorization
lu LU matrix factorization
luinc Incomplete LU factorization
planerot Givens plane rotation
qr Orthogonal-triangular decomposition
qrdelete Delete column from QR factorization
qrinsert Insert column in QR factorization
qrupdate Rank 1 update to QR factorization
qz QZ factorization for generalized eigenvalues
rsf2csf Real block diagonal form to complex diagonal form
Elementary Math
• “Trigonometric”
• “Exponential”
• “Complex”
• “Rounding and Remainder”
• “Discrete Math (e.g., Prime Factors)”
Trigonometric
acos, acosh Inverse cosine and inverse hyperbolic cosine
acot, acoth Inverse cotangent and inverse hyperbolic cotangent
acsc, acsch Inverse cosecant and inverse hyperbolic cosecant
asec, asech Inverse secant and inverse hyperbolic secant
asin, asinh Inverse sine and inverse hyperbolic sine
1-12
Mathematics
atan, atanh Inverse tangent and inverse hyperbolic tangent
atan2 Four-quadrant inverse tangent
cos, cosh Cosine and hyperbolic cosine
cot, coth Cotangent and hyperbolic cotangent
csc, csch Cosecant and hyperbolic cosecant
sec, sech Secant and hyperbolic secant
sin, sinh Sine and hyperbolic sine
tan, tanh Tangent and hyperbolic tangent
Exponential
exp Exponential
log Natural logarithm
log2 Base 2 logarithm and dissect floating-point numbers into exponent and
mantissa
log10 Common (base 10) logarithm
nextpow2 Next higher power of 2
pow2 Base 2 power and scale floating-point number
sqrt Square root
Complex
abs Absolute value
angle Phase angle
complex Construct complex data from real and imaginary parts
conj Complex conjugate
cplxpair Sort numbers into complex conjugate pairs
i Imaginary unit
imag Complex imaginary part
isreal True for real array
j Imaginary unit
real Complex real part
unwrap Unwrap phase angle
Rounding and Remainder
fix Round towards zero
floor Round towards minus infinity
ceil Round towards plus infinity
round Round towards nearest integer
mod Modulus (signed remainder after division)
rem Remainder after division
sign Signum
1-13
1 Functions By Category
Discrete Math (e.g., Prime Factors)
factor Prime factors
factorial Factorial function
gcd Greatest common divisor
isprime True for prime numbers
lcm Least common multiple
nchoosek All combinations of N elements taken K at a time
perms All possible permutations
primes Generate list of prime numbers
rat, rats Rational fraction approximation
Data Analysis and Fourier Transforms
• “Basic Operations”
• “Finite Differences”
• “Correlation”
• “Filtering and Convolution”
• “Fourier Transforms”
Basic Operations
cumprod Cumulative product
cumsum Cumulative sum
cumtrapz Cumulative trapezoidal numerical integration
max Maximum elements of array
mean Average or mean value of arrays
median Median value of arrays
min Minimum elements of array
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
var Variance
Finite Differences
del2 Discrete Laplacian
diff Differences and approximate derivatives
gradient Numerical gradient
1-14