CSC_349_HANDOUT#37 - , 2 ) 1 ( , ) ( 2 = + = y x y y x y...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
1 COMPUTER SCIENCE 349A Handout Number 37 Solution of an initial-value problem in MATLAB using a Runge-Kutta method The solver "ode45" is a variable step size (or adaptive) Runge-Kutta method that uses two Runge-Kutta formulas of orders 4 and 5; it is similar to the adaptive Runge- Kutta methods in Section 25.5 of the textbook. In their simplest form, all MATLAB ode solvers can be invoked as follows: [x, y] = solver (' f ', xspan, y0) where ' f ' is a string containing the name of the function ) , ( y x f , xspan is a vector containing the interval of integration, and y0 is the initial condition. Thus, if you have defined a MATLAB function function z = f(x, y) z = (1/x)*(y*y+y); the initial-value problem
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: , 2 ) 1 ( , ) ( 2 = + = y x y y x y can be solved on the interval [1, 3] by entering [x, y] = ode45(' f ', [1 3], -2 ) The results will be stored in the (column) vectors x and y (and will be output to the screen, if you don't put a ; at the end of this statement). In this form, ode45 automatically selects the initial step size and all subsequent step sizes, and attempts to compute the solution so that the global truncation error has a relative error less than 10 3 . For the above initial-value problem, if one enters ode45( ' f ', [1, 3], -2) without any output parameters on the left hand side of the = , then MATLAB produces a graph of the computed solution....
View Full Document

This note was uploaded on 12/10/2011 for the course CSC 349 taught by Professor Oadje during the Spring '11 term at University of Victoria.

Ask a homework question - tutors are online