02.03.2016 Views

MATLAB by rudra pratap

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

2.8 Lesson 8: Symbolic Computation<br />

47<br />

2.8 Lesson 8: Symbolic Computation<br />

This lesson requires that you have Symbolic Math Toolbox installed on<br />

your computer in addition to the standard <strong>MATLAB</strong>. The student version<br />

of <strong>MATLAB</strong> includes the Symbolic Math Toolbox. Before proceeding,<br />

other users must check (click on Help ---> Product Help or the<br />

que::;tion mark (?) on the menu bar to list installed MATLAD-related<br />

products) to see if they have access to this toolbox.<br />

Goa/: To learn how to do simple symbolic algebra in <strong>MATLAB</strong>. Such mlculaLions<br />

are done with symbolic variables without resorting to their numerical values.<br />

What you are going to learn<br />

Time Estimates<br />

Lesson: 20 minutes<br />

Exercises: 60 minutes<br />

• How to create symbolic variables and use them in defining functions.<br />

• How to manipulaLe expressions using symbolic math functions expand, simplify,<br />

subs, factor, pretty, etc.<br />

• How to differentiate and integrate functions symbolically.<br />

• How to solve simultaneous linear and nonlinear equations.<br />

Method: The most important step in carrying out symbolic computation is to<br />

declare the independent variables to be symbolic before you do anything with them.<br />

Suppose you want to use x and y as symbolic variables. Then, you can declare them<br />

to be symbolic using any of the commands that follow:<br />

• x = sym ( 'x'); y = sym ( 'y')<br />

• syms x y<br />

The command sym is the formal command for constructing objects of symbol<br />

class. You can define one symbolic variable at a time using this command. You can<br />

use additional qualifiers in the definition for the symbolic object (e.g., for restricting<br />

a variable to be only real or positive). The command syms is a shortcut to declare<br />

several variables of the same class in one shot. We will use syms in this lesson. For<br />

learning more about these commands and symbolic computation, see Chapter fl.<br />

There are three basic skills to learn in symbolic computations: (i) How to define<br />

expressions and do simple algebra with them (multiply, divide, expand, factorize,<br />

sirnpliy, etc.). (ii) How to do simple c:alculus (differentiate, integrate, etc.). (iii)<br />

How Lo solve equations-algebraic and differential cquatioul:l. Once yo u kuvw these<br />

skills (Figs. 2.10 and 2.11), you can meet most of your symbolic math calculation<br />

requirements. The rest of it is about honing these skills, learning clever shortcuts<br />

and substitutions, and establishing a personal rapport with the Symbolic Math<br />

Toolbox for having fun with these calculations.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!