ode45-f10 - ode45 Differential Equation Solver This routine...

Info icon This preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
ode45 Differential Equation Solver This routine uses a variable step Runge-Kutta Method to solve differential equations numer- ically. The syntax for ode45 for first order differential equations and that for second order differential equations are basically the same. However, the .m files are quite different. I. First Order Equations ( y 0 = f ( t, y ) y ( t 0 ) = y 0 A. Create a .m file for f ( t, y ) (see the tutorial on numerical methods and .m files on how to do this). Save file as, for example, yp.m . B. Basic syntax for ode45 . At a Matlab prompt type: [t,y]=ode45(’yp’,[t0,tf],y0); (your version of ode45 may not require brackets around t0,tf ) yp = the .m file of the function f ( t, y ) saved as yp.m t0,tf = initial and terminal values of t y0 = initial value of y at t0 C. For example, to numerically solve ( t 2 y 0 = y + 3 t y (1) = - 2 over 1 t 4: * Create and save the file yp.m for the function 1 t 2 ( y + 3 t ). * At a Matlab prompt type: [t,y]=ode45(’yp’,[1,4],-2); (your version of ode45 may not require brackets around 1,4 ) * To print results type: [t,y] *
Image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern