Specifying conditions in ode23 for some non-initial value in Matlab.

123 Views Asked by At

I want to solve a differential equation numerically between t = -pi and t = pi, but I only know the condition at t = 0 (is this still called an initial condition?). As far as I can see the condition must be set for the lowest value of t given, so here it would be for t = -pi. Is there anyway to change this or work around it?

1

There are 1 best solutions below

1
On BEST ANSWER

You'll need to run the function twice, once to get the solution on $[0,\pi]$ with tspan=[0 pi] and then again to get the solution on $[-\pi,0]$ with tspan=[0 -pi]. Note that the first number of tspan is where the initial condition is enforced, regardless of which direction time flows.