Page 120 -
P. 120

Example 4.8
                             Find the first-order iterative scheme to solve the first-order differential equa-
                             tion given by:


                                                         dy
                                                      at()  + bt y() =  u t()              (4.31)
                                                          dt
                             with the initial condition y(t ) specified.
                                                     1
                             Solution: Substituting Eq. (4.16) for the numerical differentiator in the dif-
                             ferential equation, we deduce the following first-order difference equation
                             for y(k):


                                                       −1                             
                                      yk() =  2 ak() +  bk()  2 ak y k()( − 1 ) +  ak D k() ( − 1 ) +  u k()    (4.32)
                                                       
                                            
                                                               t ∆
                                               t ∆
                                            
                                                       
                             to which we should add, in the numerical subroutine, the expression for the
                             first-order differentiator D(k) as given by Eq. (4.16). The initial condition for
                             the function at the origin of time, specify the first elements of the y and D
                             arrays:
                                                  y()1 =  y t( =  t )
                                                            1
                                                  D()1 =  ( /1  a())[1  u()1 −  b()1  y()]1


                             Application
                             To illustrate the use of the above algorithm, let us solve, over the interval 0 ≤
                             t ≤ 6, for the potential across the capacitor in an RC circuit with an ac source;
                             that is,


                                                        dy
                                                       a   +  y = sin(2π t)                (4.33)
                                                        dt
                             where a = RC and y(t = 0) = 0.

                             Solution: Edit and execute the following script M-file, for a = 1/(2π):

                                tin=0;
                                tfin=6;
                                t=linspace(tin,tfin,3000);
                                N=length(t);
                                y=zeros(1,N);


                             © 2001 by CRC Press LLC
   115   116   117   118   119   120   121   122   123   124   125