Matlab allows you to create symbolic math expressions. This is useful when you don't want to immediately compute an answer, or when you have a math "formula" to work on but don't know how to "process" it.
Matlab allows symbolic operations several areas including:
- Linear Algebra
- Algebraic and Differential Equations
- Transforms (Fourier, Laplace, etc)
The key function in Matlab to create a symbolic representation of data is: sym() or syms if you have multiple symbols to make.
Below is an example of creating some symbolic fractions and square roots:
Defining Symbolic Expressions
We can define symbolic functions using the sym command and syms command. Here is an example of creating a symbolic function
for (a*X^2) + (b*x) + c:
From now on we can use the f symbol to represent the given function.
Evaluation of Symbolic Expressions
The keyfunction subs (which stands for substitute) is used to replace symbolic variables with either new symbolic variables or with acutal values. The syntax for the function is: subs( symbolic_function, list_of_symbols, list_of_values). Here is an example:
Plotting Symbolic Function
In Matlab, we can plot a symbolic function over one variable by using the ezplot function. Here is an example:
If you want to see something cool, try:
Or plotting a polynomial equation:
Integration and Derivation
Matlab can also compute many integrals and derivatives that you might find in Calculus or many advanced engineering courses.