Defining Boundary Conditions - How?

Hello there,
I was trying to script the following ODE problem to solve it on matlab:
Considering the following bondary conditions:
What would be the best way to define the last two BCs?
How could I script then in MATLAB language?
Currently, I am using MATLAB R2015a.
Thank you for the help!
Gabriel

 Respuesta aceptada

Ameer Hamza
Ameer Hamza el 14 de Jun. de 2020
This link shows how to use bvp5c to solve multiple boundary condition problem: https://www.mathworks.com/help/matlab/math/solve-bvp-with-multiple-boundary-conditions.html. Try following code.
L = 3;
xmesh = [linspace(0, L/2, 50) linspace(L/2, L, 50)];
yguess = bvpinit(xmesh, [0; 0]);
sol = bvp5c(@odefun, @bcFun, yguess);
plot(sol.x, sol.y);
legend({'$y$', '$\dot{y}$'}, ...
'Interpreter', 'latex', ...
'FontSize', 16, ...
'Location', 'best');
function dydx = odefun(x, y, region)
W = 1;
T = 2;
dydx = zeros(2, 1);
dydx(1) = y(2);
if region==1
dydx(2) = 3*W/T;
else
dydx(2) = W/T;
end
end
function res = bcFun(yl, yr)
res = [yl(1,1) - 0; % y(0)=0
yr(1,1) - yl(1,2); % y(L/2-)=y(L/2+)
yr(2,1) - yl(2,2); % y'(L/2-)=y'(L/2+)
yr(1,2)]; % y(L)=0
end

1 comentario

Gabriel Coelho
Gabriel Coelho el 30 de Jun. de 2020
Excelent! Thanks a lot
Any ideas on how to define the boundary conditions with symbolic?

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Symbolic Math Toolbox en Centro de ayuda y File Exchange.

Productos

Versión

R2015a

Preguntada:

el 13 de Jun. de 2020

Comentada:

el 30 de Jun. de 2020

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by