ode45-f10

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

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

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] *

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

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### What students are saying

• 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.

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

• 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.

Dana University of Pennsylvania ‘17, Course Hero Intern

• 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.

Jill Tulane University ‘16, Course Hero Intern