
If there are more variables than equations, you should tell Matlab which ones to solve for, by putting the variable names at the end. All equations have to be of the form expression = 0, and only the expression is entered. The solve command tries to solve one or more equations in closed form. It is better to spell it out which variable you want.

If there are multiple variables, it has some complicated precedence rules. If f is a function of x only, Matlab will integrate or differentiate with respect to x automatically. The general rule is: if there is no ambiguity, you don't have to specify the variable (but it doesn't hurt). > int(f,y,1,2) % definite integral wrt y from 1 to 2 > int(f,x,1,2) % definite integral wrt x from 1 to 2 > diff(f,x) % differentiate with respect to x Integration and differentiation are quite straightforward: If your symbolic expression is a number, the double command turns it back into a numerical value.ģ.141592653589793 Integration and Differentiation

You can replace any subexpression by something else. You have to use the subs command (substitution). How do you evaluate that for x=2? You cannot simply write f(2). Suppose you have some symbolic expression, such as f = x^2 - 1. Typing it in with apostrophes is a safer choice. The denominator will be some large power of 2. If it can't guess, it simply converts the machine number to an exact fraction. For example, sym(1/3) and sym('1/3') give the same result: It recognizes some things, like simple multiples of pi, or fractions whose numerator and denominator are not too large. You can also use sym to convert easy numbers to symbolic. > syms x aĪlternatively, you can use the sym command to convert a string into a symbolic expression. If you are planning to take a transpose of a vector or matrix, add 'real' (with or without apostrophes) to the end of the declaration, otherwise Matlab will stick a conj (complex conjugate) on everything. The syms command creates empty symbolic variables, which you can then combine into expressions. Symbolic variables and expressions have data type sym. Most of them have more features than described here. Type help symbolic for more information about the symbolic toolbox in general, and explore the help files for individual commands. What you find here should be enough for this class, and it will get you started for more complicated things. There are many more fancy things you can do symbolically. What I am describing here is fairly basic. The actual MuPad program, or other programs such as Maple or Mathematica, are probably more powerful than what you can do through Matlab, but the Matlab interface is usually enough for my purposes. Matlab translates that into whatever form MuPad wants, and translates the output back.

You type in your symbolic expressions in Matlab syntax. Maple was a lot better I have run into multiple examples where I used to be able to calculate something a few years ago, but now it does not work any more. Matlab has licensed an interface to a separate symbolic calculator. Symbolic computation is not really part of Matlab itself. Symbolic Computation in Matlab Symbolic Computation in Matlab Overview
