Solve second-order ODE with Robin boundary condition

Hello,
I would like to solve the following ODE equation with boundary conditions. A,B,C and a,b are constants.
I already wrote the odefun as below :
function dy = odefun(x,y)
dy = zeros(2,1);
dy(1) = y(2);
dy(2) = (2/(x^2))*y(1)-(2/x)*y(2);
end
Afterwards, should I use ODE45 or dvp4c or another solver ? How can I apply boundary condtion to the solver ?
At the end, I want to plot dydx in y-axis versus x in x-axis. How can I deal with this ?
I'd appreciate your help !

 採用された回答

Torsten
Torsten 2024 年 2 月 27 日
編集済み: Torsten 2024 年 2 月 27 日

0 投票

syms x y(x) A B C a b
dy = diff(y,x);
eqn = diff(x^2*dy,x)-2*y == 0;
cond1 = A*dy(a)+B*y(a)/a == 0;
cond2 = A*dy(b)+B*y(b)/b == C;
conds = [cond1,cond2];
sol = dsolve(eqn,conds)
sol = 

1 件のコメント

Qian
Qian 2024 年 2 月 28 日
It's great ! Thank you Torsten.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

製品

リリース

R2022b

タグ

質問済み:

2024 年 2 月 27 日

コメント済み:

2024 年 2 月 28 日

Community Treasure Hunt

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

Start Hunting!

Translated by