# How do I solve a boundary value ODE in MATLAB?

Specifically, ode15i. I have ode15i solving a system of 5 first order implicit odes in 5 variables with an initial condition (made consistent by decic). It's great for what I need, except I need to add a final condition as well. Is this possible? I think (but am not sure) ode15s works too.

Edit: -

Edit 2: I think I figured it out. I'm going to make dummy variables for all the derivatives, add in a bunch of extra equations, and that should make the equations "explicit" so I can use bvp4c.

• Just to clarify, you have $y(0)$ as the initial condition and you also need that $y(T)$ be the specified value from your application. Jul 23, 2013 at 21:04
• Would you mind providing more details
– Paul Renton
Jul 23, 2013 at 21:26
• We are going to need more datails. Unless there are tunable parameters in your equations (or you initial conditions) the equations are over-determined. Jul 23, 2013 at 22:52
• What details do you need? The five variables are all functions of t, and I would like to set (only one or two) of them with a boundary condition at a set time t. Jul 23, 2013 at 22:58
• Are you simply asking to stop the solver when/if $y(t)$ reaches a critical value, or are you saying that $y(t)$ must reach that critical value at a set time? The former isn't a boundary condition but rather a special termination condition (that can easily be handled with MATLAB's ODE solvers.) Jul 23, 2013 at 22:59

The MATLAB routines starting with 'ode', like ode15i, are for solving initial value problems. If you want to solve a boundary value problem, use bvp4c or bvp5c.

• The problem is, bvp4c and bvp5c are only for explicit equations. My equations are all very much implicit. Jul 24, 2013 at 16:54
• In order to make your question useful to others, could you please write down one of your BVPs? This will make it clear what you mean by "implicit". Jul 24, 2013 at 23:15

I assume that you want to solve $$f(t,y',y)=0 \text{ on } (0,T)$$ with two-point boundary values $$y(0)=\alpha \text{ and } y(T)=\beta.$$

You cannot simply apply ODE solvers to this problen unless you take the heuristic approach of forward-backward iteration (see the list below).

There is no general approach to these boundary value problems. And I don't didn't know of any built-in function in Matlab that solves these boundary value problems even for the case with $y' = \tilde f (t,y)$.

[EDIT: There are matlab functions for solving these semi-explicit two point boundary value problems, see David Ketcheson's answer, that use finite differences and collocation. ]

• Finite Differences: Discretize the interval $[0,T]$, if necessary do a collocation, and solve the resulting algebraic system