MATLAB Tutor
Part 9: Symbolic Matrices
MATLAB's Symbolic Math Toolbox
allows you to use symbols when doing matrix algebra.
- Whenever you want to define a matrix
that includes symbols, you must first declare those variables symbolic by
using the "syms" command.
Enter
syms t % t is a symbolic
variable
A = [cos(t) sin(t); -sin(t) cos(t)]
det(A)
best = simple(ans)
- Compare the result of step 1
to the one you get when you enter the following statements:
t = 5 % t has a numeric value
format short % show decimal format
A = [cos(t) sin(t); -sin(t) cos(t)]
det(A)
- It is just as easy to
declare two or more variables symbolic as one. Enter
syms a b c d % Create symbolic variables
M = [a b; c d] % Create a symbolic matrix
det (M) % Find the determinant of M
Did you get the answer you expected?
- Enter the following set of commands.
Be sure you understand what happens after each one is performed.
syms lambda
A = [1 2; 3 8]
I = eye(2)
M = A - lambda*I
cpoly = det(M)
solve(cpoly) % roots of quadratic
double(ans)
|
CCP Home |
Materials | Linear Algebra | Module Contents | Back | Forward |