CHAPTER 1

image

Symbolic Variables and Functions

1-1. Symbolic Variables

MATLAB deems as symbolic any algebraic expression whose variables have all been previously defined as symbolic; variables are declared as symbolic using the command syms. For example, if we want to treat as symbolic the expression 6 * a * b + 3 * a^2 + 2 * a * b, in order to simplify it, we need to declare the two variables a and b as symbolic, as shown here:

>> syms a b>> simplify(6*a*b + 3*a^2 + 2*a*b)
ans =8 * a * b + 3 * a ^ 2

As we will see, the command needed to transform a numeric expression to symbolic is sym. For example, if we want to simplify the numeric expression ...

Get MATLAB Symbolic Algebra and Calculus Tools now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.