12.07.2015 Views

GNU Octave - Local Sector 7 web page

GNU Octave - Local Sector 7 web page

GNU Octave - Local Sector 7 web page

SHOW MORE
SHOW LESS
  • No tags were found...

Create successful ePaper yourself

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

Chapter 23: Differential Equations 191function xdot = f (x, t)xdot = zeros (3,1);xdot(1) = 77.27 * (x(2) - x(1)*x(2) + x(1) \- 8.375e-06*x(1)^2);xdot(2) = (x(3) - x(1)*x(2) - x(2)) / 77.27;xdot(3) = 0.161*(x(1) - x(3));endfunctionand the initial condition x0 = [ 4; 1.1; 4 ], the set of equations can be integrated usingthe commandt = linspace (0, 500, 1000);y = lsode ("f", x0, t);If you try this, you will see that the value of the result changes dramatically between t= 0 and 5, and again around t = 305. A more efficient set of output points might bet = [0, logspace (-1, log10(303), 150), \logspace (log10(304), log10(500), 150)];See Alan C. Hindmarsh, ODEPACK, A Systematized Collection of ODE Solvers, inScientific Computing, R. S. Stepleman, editor, (1983) for more information about the innerworkings of lsode.23.2 Differential-Algebraic EquationsThe function daspk can be used to solve DAEs of the form0 = f(ẋ, x, t), x(t = 0) = x 0 , ẋ(t = 0) = ẋ 0using Petzold’s DAE solver Daspk.[x, xdot, istate, msg] = daspk (fcn, x 0, xdot 0, t, t crit)Solve the set of differential-algebraic equationsLoadable Function0 = f(x, ẋ, t)withx(t 0 ) = x 0 , ẋ(t 0 ) = ẋ 0The solution is returned in the matrices x and xdot, with each row in the resultmatrices corresponding to one of the elements in the vector t. The first element of tshould be t 0 and correspond to the initial state of the system x 0 and its derivativexdot 0, so that the first row of the output x is x 0 and the first row of the outputxdot is xdot 0.The first argument, fcn, is a string that names the function to call to compute thevector of residuals for the set of equations. It must have the form

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

Saved successfully!

Ooh no, something went wrong!