Solve second-order ODE with Robin boundary condition

7 views (last 30 days)
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 !

Accepted Answer

Torsten
Torsten on 27 Feb 2024
Edited: Torsten on 27 Feb 2024
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 = 

More Answers (0)

Products


Release

R2022b

Community Treasure Hunt

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

Start Hunting!