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

 채택된 답변

Ameer Hamza
Ameer Hamza 2020년 6월 14일

1 개 추천

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

Gabriel Coelho
Gabriel Coelho 2020년 6월 30일
Excelent! Thanks a lot
Any ideas on how to define the boundary conditions with symbolic?

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Symbolic Math Toolbox에 대해 자세히 알아보기

제품

릴리스

R2015a

질문:

2020년 6월 13일

댓글:

2020년 6월 30일

Community Treasure Hunt

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

Start Hunting!

Translated by