Page 56 - MATLAB an introduction with applications
P. 56

MATLAB Basics ——— 41


                   1.19.2 Solution to Differential Equations
                   Symbolic math functions can be used to solve a single equation, a system of equations and differential
                   equations. For example:
                   solve( f ) : Solves a symbolic equation f for its symbolic variable. If f is a symbolic expression, this function
                            solves the equation f = 0 for its symbolic variable.
                   solve(f1, …, fn): Solves the system of equations represented by f 1, …, f n.
                   The symbolic function for solving ordinary differential equation is dsolve as shown below:
                   dsolve(‘equation’, ‘condition’): Symbolically solves the ordinary differential equation specified by ‘equation’.
                   The optional argument ‘condition’ specifies a boundary or initial condition.
                   The symbolic equation uses the letter D to denote differentiation with respect to the independent variable.
                   D followed by a digit denotes repeated differentiation. Thus, Dy represents dy/dx, and D2y represents
                        2
                    2
                   d y/dx .  For example, given the ordinary second order differential equation;
                                   2
                                  dx  + 5  dx  + x  7
                                            3 =
                                  dt 2   dt
                   with the initial conditions x(0) = 0 and  (0)x     = 1.
                   The MATLAB statement that determines the symbolic solution for the above differential equation is the
                   following:
                              x = dsolve(‘D2x = –5*Dx – 3*x + 7’, ‘x(0) = 0’, ‘Dx(0) =1’)
                   The symbolic functions are summarized in Table 1.37.
                                                Table 1.37 Solution of equations
                                    compose       Functional composition
                                    dsolve        Solution of differential equations
                                    finverse      Functional inverse
                                    solve         Solution of algebraic equations

                   1.19.3 Calculus
                   There are four forms by which the symbolic derivative of a symbolic expression is obtained in MATLAB.
                   They are:
                   diff( f )  : Returns the derivative of the expression f with respect to the default independent variable.
                   diff( f, ‘t’) : Returns the derivative of the expression f with respect to the variable t.
                   diff( f, n)  : Returns the nth derivative of the expression f with respect to the default independent variable.
                   diff( f,‘t’, n) : Returns the nth derivative of the expression f with respect to the variable t.

                   The various forms that are used in MATLAB to find the integral of a symbolic expression f are given and
                   summarized in Table 1.38.

                   int( f )  : Returns the integral of the expression f with respect to the default independent variable.
                   int( f,  ‘t’) : Returns the integral of the expression f with respect to the variable t.
                   int( f, a, b) : Returns the integral of the expression f with respect to the default independent variable
                               evaluated over the interval [a, b], where a and b are numeric expressions.
                   int(f,‘t’, a, b): Returns the integral of the expression f  with respect to the variable t evaluated over the
                               interval [a, b], where a and b are numeric expressions.








                   F:\Final Book\Sanjay\IIIrd Printout\Dt. 10-03-09
   51   52   53   54   55   56   57   58   59   60   61