Matlab Tips and Tricks-2
Clearly, it is important to know the language you intend to use. The language is described in the
manuals so I won’t repeat what they say, but I encourage you to type
at the command prompt and take a look at the list of operators, functions and special characters, and
look at the associated help pages.
When manipulating arrays in M AT L A B there are some operators and functions that are particu-
In addition to the arithmetic operators, M AT L A B provides a couple of other useful operators
The colon operator.
Type help colon for more information.
Type help transpose for more information.
Complex conjugate transpose.
Type help ctranspose for more information.
True if all elements of a vector are nonzero.
True if any element of a vector is nonzero.
Cumulative sum of elements.
Diagonal matrices and diagonals of a matrix.
Difference and approximate derivative.
Last index in an indexing expression.
Find indices of nonzero elements.
True for empty matrix.
True if arrays are numerically equal.
True for ï¬nite elements.
True for inï¬nite elements.
True for logical array.
True for Not-a-Number.
True for numeric arrays.
Length of vector.
Convert numeric values to logical.
Number of dimensions.
Number of elements in a matrix.
Permute array dimensions.
Product of elements.
Size of matrix.
Sort in ascending order.
Sum of elements.
Extract lower triangular part.
Extract upper triangular part.
Some of these functions are shorthands for combinations of other built-in functions, lik
Others are shorthands for frequently used tests, like
isempty(x) numel(x) == 0
isinf(x) abs(x) == Inf
isfinite(x) abs(x) ~= Inf
Others are shorthands for frequently used functions which could have been written with low-level
code, like diag, eye, find, sum, cumsum, cumprod, sort, tril, triu, etc.
Flip matrix along speciï¬ed dimension.
Flip matrix in left/right direction.
Flip matrix in up/down direction.
Multiple subscripts from linear index.
Inverse permute array dimensions.
Kronecker tensor product.
Linearly spaced vector.
Generation of arrays for N-D functions and interpolation.
Replicate and tile an array.
Rotate matrix 90 degrees.
Remove singleton dimensions.
Linear index from multiple subscripts.