mat lab 0de45 - Bucknell University Using ODE45 MATLAB Help...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
Bucknell University Using ODE45 1 Bucknell University Using ODE45 MATLAB Help MATLAB's standard solver for ordinary differential equations (ODEs) is the function ode45 . This function implements a Runge-Kutta method with a variable time step for efficient computation. ode45 is designed to handle the following general problem d y dt = f ( t , y ) y ( t o ) = y o [1] where t is the independent variable (time, position, volume) and y is a vector of dependent variables (temperature, position, concentrations) to be found. The mathematical problem is specified when the vector of functions on the right-hand side of Eq. [1], f ( t , y ) , is set and the initial conditions, y = y o at time t o , are specified. The notes here apply to versions of MATLAB above 5.0 and cover the basics of using the function ode45 . For more information on this and other ODE solvers in MATLAB, see the on-line help. Contents: Syntax for ode45 ................................................................................................................................... 2 Integrating a single, first-order equation . ............................................................................................... 3 Getting the solution at particular values of the independent variable . ................................................... 4 Using in-line functions . .......................................................................................................................... 4 Integrating a set of coupled first-order equations. .................................................................................. 5 Integrating a second-order initial-value problem (IVP) . ........................................................................ 7 Integrating an N th-order initial-value problem. ...................................................................................... 8 Changing model parameters. .................................................................................................................. 9 Using anonymous functions . ................................................................................................................. 10 Integrating a second-order boundary-value problem (BVP). ............................................................... 12 Setting options in ode45 ...................................................................................................................... 14 Going beyond ode45 ........................................................................................................................... 14 Revised: August 2010
Background image of page 1

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

View Full DocumentRight Arrow Icon
Bucknell University Using ODE45 2 Syntax for ode45 ode45 may be invoked from the command line via [t,y] = ode45(fname, tspan, y0, opts) where fname name of the function Mfile or inline function used to evaluate the right-hand-side function in Eq. [1] at a given value of the independent variable and dependent variable(s) (string (if Mfile) or inline object). The function definition line usually has the form function dydt = fname(t,y) The output variable ( dydt ) must be a vector with the same size as y . Note that the independent variable ( t here) must be included in the input argument list even if it does not explicitly appear in the expressions used to generate dydt . The variable fname can contain the name of the Mfile as a string or fname may be a function handle generated by an inline or anonymous function. tspan 2-element vector defining the range of integration ( [to tf] ) though variations are possible. y0 vector of initial conditions for the dependent variable. There should be as many initial conditions as there are dependent variables. opts a MATLAB structure variable (created by odeset ) that allows you to control the details of computation (if you want to). This argument is optional and, if not provided, ode45 will use default values (see the examples below). t Value of the independent variable at which the solution array ( y ) is calculated. Note that by default this will not be a uniformly distributed set of values.
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 15

mat lab 0de45 - Bucknell University Using ODE45 MATLAB Help...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online