Can someone help me solve this different equation on matlab?

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
Eqn(r) = 
S = dsolve(Eqn, S(0) == S0)
S = 
.

6 Comments

What if c1 and c2 are function of S too
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.
then use that result with an appropriate numerical solver, such as ode45 or ode15s.
In this case: bvp4c or bvp5c.
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.
Thank you everyone for the comments, Sam, the problem actually is related to plasma physics, i am trying to solve the Elenbaas Heller equation, which is the energy balance all function of what we call the heat flux, denoted as “S”. Basically, the differential equation I am trying to solve is the following: 1/r * d/dr(r*dS/dr) + sigma(S)*E^2 - 4*pi*epsilon(S) = 0 E is the electric field which is given (i’ll actually have to use a for loop to solve for several E values to draw a graph, but it is given not calculated), sigma(S) is the electric conductivity function of S, and epsilon(S) is a radiation parameter also function of S. r is the radius of the plasma, and i need to solve the differential equation to find the heat flux “S”
I know boundary conditions: S(r=0)=0 and dS(r=rmax)/dr=0
It would be easiest if you include your attempt where you (unsuccessfully) used "bvp4c".

Sign in to comment.

Asked:

Jad
on 18 Feb 2024

Commented:

on 18 Feb 2024

Community Treasure Hunt

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

Start Hunting!