Function Reference

Matrix Manipulation

Finding Elements and Checking Conditions

any
For a vector argument, return 1 if any element of the vector is nonzero.
all
The function `all' behaves like the function `any', except that it returns true only if all the elements of a vector, or all the elements along dimension DIM of a matrix, are nonzero.
xor
Return the `exclusive or' of the entries of X and Y.
is_duplicate_entry
Return non-zero if any entries in X are duplicates of one another.
diff
If X is a vector of length N, `diff (X)' is the vector of first differences X(2) - X(1), .
isinf
Return 1 for elements of X that are infinite and zero otherwise.
isnan
Return 1 for elements of X that are NaN values and zero otherwise.
finite
Return 1 for elements of X that are finite values and zero otherwise.
find
Return a vector of indices of nonzero elements of a matrix, as a row if X is a row or as a column otherwise.
common_size
Determine if all input arguments are either scalar or of common size.

Rearranging Matrices

fliplr
Return a copy of X with the order of the columns reversed.
flipud
Return a copy of X with the order of the rows reversed.
flipdim
Return a copy of X flipped about the dimension DIM.
rot90
Return a copy of X with the elements rotated counterclockwise in 90-degree increments.
rotdim
Return a copy of X with the elements rotated counterclockwise in 90-degree increments.
cat
Return the concatenation of N-d array objects, ARRAY1, ARRAY2, .
horzcat
Return the horizontal concatenation of N-d array objects, ARRAY1, ARRAY2, .
vertcat
Return the vertical concatenation of N-d array objects, ARRAY1, ARRAY2, .
permute
Return the generalized transpose for an N-d array object A.
ipermute
The inverse of the `permute' function.
reshape
Return a matrix with the given dimensions whose elements are taken from the matrix A.
circshift
Circularly shifts the values of the array X.
shiftdim
Shifts the dimension of X by N, where N must be an integer scalar.
shift
If X is a vector, perform a circular shift of length B of the elements of X.
sort
Return a copy of X with the elements arranged in increasing order.
sortrows
Sort the rows of the matrix A according to the order of the columns specified in C.
swap
Not implemented.
swapcols
Not implemented.
swaprows
Not implemented.
tril
Return a new matrix formed by extracting the lower (`tril') or upper (`triu') triangular part of the matrix A, and setting all other elements to zero.
vec
Return the vector obtained by stacking the columns of the matrix X one above the other.
vech
Return the vector obtained by eliminating all supradiagonal elements of the square matrix X and stacking the result one column above the other.
prepad
Prepends (appends) the scalar value C to the vector X until it is of length L.
blkdiag
Build a block diagonal matrix from A, B, C, .

Applying a Function to an Array

arrayfun
Execute a function on each element of an array.
bsxfun
Applies a binary function F element-wise to two matrix arguments A and B.

Special Utility Matrices

eye
Return an identity matrix.
ones
Return a matrix or N-dimensional array whose elements are all 1.
zeros
Return a matrix or N-dimensional array whose elements are all 0.
repmat
Form a block matrix of size M by N, with a copy of matrix A as each element.
rand
Return a matrix with random elements uniformly distributed on the interval (0, 1).
randn
Return a matrix with normally distributed pseudo-random elements having zero mean and variance one.
rande
Return a matrix with exponentially distributed random elements.
randp
Return a matrix with Poisson distributed random elements.
randg
Return a matrix with `gamma(A,1)' distributed random elements.
randperm
Return a row vector containing a random permutation of the integers from 1 to N.
diag
Return a diagonal matrix with vector V on diagonal K.
linspace
Return a row vector with N linearly spaced elements between BASE and LIMIT.
logspace
Similar to `linspace' except that the values are logarithmically spaced from 10^base to 10^limit.

Famous Matrices

hadamard
Construct a Hadamard matrix HN of size N-by-N.
hankel
Return the Hankel matrix constructed given the first column C, and (optionally) the last row R.
hilb
Return the Hilbert matrix of order N.
invhilb
Return the inverse of a Hilbert matrix of order N.
magic
Create an N-by-N magic square.
pascal
Return the Pascal matrix of order N if `T = 0'.
rosser
Returns the Rosser matrix.
sylvester_matrix
Return the Sylvester matrix of order n = 2^k.
toeplitz
Return the Toeplitz matrix constructed given the first column C, and (optionally) the first row R.
vander
Return the Vandermonde matrix whose next to last column is C.
wilkinson
Return the Wilkinson matrix of order N.