In addition to doing numeric computations, it is possible to do symbolic calculations with MATLAB’s symbolic toolbox. The symbolic toolbox allows us to manipulate symbolic expressions. It can be used to solve equations, differentiate and integrate functions, and perform symbolic matrix operations.
MATLAB’s sym
command can be used to turn any MATLAB data structure into a symbolic object. For example, the command sym(‘t’)
will turn the string ‘t’
into a symbolic variable t
, and the command sym(hilb(3))
will produce the symbolic version of the Hilbert matrix written in the form
We can create a number of symbolic variables at once with the syms
command. For example, the command
creates three symbolic variables a, b
, and c
. If we then set
the result will be the symbolic matrix
The MATLAB command subs
can be used to substitute an expression or a value for a symbolic variable. For example, the command subs(A, c, 3)
will substitute 3 for each occurrence of c in the symbolic matrix A. Multiple substitutions are also possible: The command
will substitute , and 3 for a, b
, and c
, respectively, in the matrix A.
The standard matrix operations ∗,ˆ, +, −, and ′ all work for symbolic matrices and also for combinations of symbolic and numeric matrices. If an operation involves two matrices and one of them is symbolic, the result will be a symbolic matrix. For example, the command
will produce the symbolic matrix
Standard MATLAB matrix commands such as
all work for symbolic matrices; however, others such as
do not. Likewise, none of the standard matrix factorizations are possible for symbolic matrices.
18.222.200.143