Can someone help me solve this different equation on matlab?
Show older comments
Hi everyone, I am trying to solve the following equation: 1/r * d/dr(r*dS/dr) + c1(S) - c2(S) = 0 I am trying to solve to find the value of “S”, r is the radius, and c1 and c2 are properties with values depending on S, how can I solve this on matlab? I tried using bvp4c but I probably put the wrong ode and wrong initial guesses so it wasn’t converging
Answers (1)
Perhaps this —
% 1/r * d/dr(r*dS/dr) + c1 - c2
syms r S(r) c1 c2 S0 DS0
Eqn = 1/r * diff(r*diff(S),r) + c1 - c2
S = dsolve(Eqn, S(0) == S0)
.
6 Comments
Jad
on 18 Feb 2024
Star Strider
on 18 Feb 2024
Then code them appropriately for that. You may still be able to get a symbolic result.
If as the result the differential equation is nonlinear, dsolve will probably not be able to solve it. In that instance, first use the odeToVectorField function and then matlabFunction on the first output (always request both outputs so you know what it did), and then use that result with an appropriate numerical solver, such as ode45 or ode15s.
Torsten
on 18 Feb 2024
then use that result with an appropriate numerical solver, such as ode45 or ode15s.
In this case: bvp4c or bvp5c.
Sam Chak
on 18 Feb 2024
Hi Jade, I'm unsure but the nature of the equation suggests that the problem is related to the heat transfer and it lies inside a concentric sphere.
Knowing the type of problem allows us to assess whether ode45 or bvp4c is appropriate.
Torsten
on 18 Feb 2024
It would be easiest if you include your attempt where you (unsuccessfully) used "bvp4c".
Categories
Find more on Numeric Solvers in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!