The both bvp4c and bpv5c solvers can find the solution for piecewise defined equations. In this case the solution must be smooth at each region. At the borders you can specify additional conditions. Here is the link which describes how to do that: http://www.mathworks.com.au/help/matlab/math/boundary-value-problems.html
Solving boundary value problem for piecewise defined differential equation
4 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Evgeniy
el 14 de En. de 2014
Respondida: Evgeniy
el 12 de Feb. de 2014
Greetings. I faced the problem with solving the system of differential equations showed below. This system contains two equations (one for each interval). Due to the fact that these are 2-nd order differential equations and I don't know the values of derivatives at the ends (y'(-20) and y'(10)) this is boundary problem and the system could be solved by bvp4c function.
The problem is how to define the condition of the first derivatives near the 0 (bottom of the picture). I tried to do this:
function [ dydx ] = tode( x , y )
dydx = zeros(2,1); % create zero array
dydx(1) = y(2);
if (x > 0)
dydx(2) = b/a*((1+y(1))^(3/2)-1);
elseif (x <= 0)
dydx(2) = 0;
end;
end
But this expression doesn't include the condition of first-order derivatives. How can I solve the problem? Thank you.

%
0 comentarios
Respuesta aceptada
Más respuestas (4)
Mischa Kim
el 14 de En. de 2014
Editada: Mischa Kim
el 14 de En. de 2014
Look at this problem as an initial value problem and turn it into an optimization problem:
- Set up an algorithm that integrates the piece-wise function from the left, that is in [-20,0], and, separately, from the right, in [10,0]. The only unknowns are the two first derivatives of y at the boundaries (let's call them yp = [yp1, yp2] ), correct? So you have to make a guess.
- Once you have performed the integration, the two boundary conditions at x=0 (most likely) will not be satisfied: dy(0)≠ 0, dyp(0)≠ 0 .
- You should then be able to use a root-finding algorithm (e.g. Newton-Raphson) to find the root of the cost function J of the optimization, which in this case is J = norm([dy(0);dyp(0)]). Note, when both boundary conditions at x=0 are satisfied, J=0 .
3 comentarios
Mischa Kim
el 16 de En. de 2014
Editada: Mischa Kim
el 16 de En. de 2014
Well, in this case the problem becomes much easier. Solve the initial value problem in x = [10,0] (using, e.g., ode45). This will give you y(0+) and y'(0+), which you can use for the initial conditions for the second integration in x = [0,-20]. Problem solved.
In fact, since the 2nd differential equation has such an easy form, you can do this part by hand.
Note, however, that y(-20) = 5, which needs to be confirmed by the second integration. If the result differs your previous assumption (99%) was not correct. Are all the constants known?
Bjorn Gustavsson
el 17 de En. de 2014
Second differential equation should give you a simple first order polynomial:
y = 5 + C * (20 + x)
That should give you simple expressions of both y(-0) and dy/dx(-0). That should be possible to solve with the suggested shooting method for only the possitive ODE - but taking into account both y(+0) and dy/dx(+0)
0 comentarios
Ver también
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

