Symbolic Toolbox

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 3×3 Hilbert matrix written in the form

[1,12,13][12,13,14][13,14,15]

We can create a number of symbolic variables at once with the syms command. For example, the command

symsabc

creates three symbolic variables a, b, and c. If we then set

A=[a,b,c;b,c,a;c,a,b]

the result will be the symbolic matrix

A=[a,b,c][b,c,a][c,a,b]

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

subs(A,[a,b,c],[a1,b+1,3])

will substitute a1,b+1, 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

sym(hilb(3))+eye(3)

will produce the symbolic matrix

[2,12,13][12,43,14][13,14,65]

Standard MATLAB matrix commands such as

det,eig,inv,null,trace,sum,prod,poly

all work for symbolic matrices; however, others such as

rref,orth,rank,norm

do not. Likewise, none of the standard matrix factorizations are possible for symbolic matrices.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.222.200.143