Go to CCP Homepage Go to Materials Page Go to Linear Algebra Materials Go to Table of Contents
Go Back One Page Go Forward One Page

MATLAB Tutor

Part 9: Symbolic Matrices

MATLAB's Symbolic Math Toolbox allows you to use symbols when doing matrix algebra.

  1. 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)
  2. 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)
  3. 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?
  4. 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)

Go to CCP Homepage Go to Materials Page Go to Linear Algebra Materials Go to Table of Contents
Go Back One Page Go Forward One Page


| CCP Home | Materials | Linear Algebra | Module Contents | Back | Forward |

modules at math.duke.edu Copyright CCP and the author(s), 2000