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 ExchangeSymbolic Math Toolbox についてさらに検索

製品

リリース

R2015a

Community Treasure Hunt

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

Start Hunting!

Translated by