Page 67 - Applied Numerical Methods Using MATLAB
P. 67

56    MATLAB USAGE AND COMPUTATIONAL ERRORS
                   vector of the integral polynomial for a given polynomial coefficient
                   vector.
                   (cf) MATLAB has the built-in routines polyder()/polyint() for finding the
                       derivative/integral of a polynomial.


                     function  pd = poly_der(p)
                     %p: the vector of polynomial coefficients in descending order
                     N = length(p);
                     if N <= 1,  pd = 0; % constant
                     else
                      fori=1:N- 1, pd(i)     = p(i)*(N - i); end
                     end

                (f) Roots of A Polynomial Equation: roots()
                   Write a MATLAB statement to get the roots of the following polynomial
                   equation
                                                 8
                                         p(x) = x − 1 = 0              (P1.11.5)
                   You can check if the result is right, by using the MATLAB command
                   poly(), which generates a polynomial having a given set of roots.
                (g) Partial Fraction Expansion of a Ratio of Two Polynomials: residue()/
                   residuez()
                     (i) The MATLAB routine [r,p,k] = residue(B,A) finds the partial
                        fraction expansion for a ratio of given polynomials B(s)/A(s) as

                         B(s)    b 1 s M−1  + b 2 s M−2  +· · · + b M     r(i)
                              =                           = k(s) +
                         A(s)    a 1 s N−1  + a 2 s N−2  + ··· + a N  s − p(i)
                                                                   i
                                                                      (P1.11.6a)
                        which is good for taking the inverse Laplace transform. Use this
                        routine to find the partial fraction expansion for
                                         4s + 2
                            X(s) =                  =       +      +
                                    3
                                         2
                                   s + 6s + 11s + 6   s +     s +    s +
                                                                      (P1.11.7a)
                    (ii) The MATLAB routine [r,p,k] = residuez(B,A) finds the par-
                        tial fraction expansion for a ratio of given polynomials B(z)/A(z)
                        as

                        B(z)   b 1 + b 2 z −1  +· · · + b M z −(M−1)  −1     r(i)z
                             =                           = k(z ) +
                        A(z)   a 1 + a 2 z −1  +· · · + a N z −(N−1)   z − p(i)
                                                                     i
                                                                      (P1.11.6b)
                        which is good for taking the inverse z-transform. Use this routine
                        to find the partial fraction expansion for
                                        4 + 2z −1          z       z      z
                          X(z) =                       =      +      +
                                 1 + 6z −1  + 11z −2  + 6z −3  z +  z +  z +
                                                                      (P1.11.7b)
   62   63   64   65   66   67   68   69   70   71   72