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 the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.