How do I input a condition to numerically solve an ODE that does not have the variable = 0?

I'm attempting to solve the follwing ODE:
dfdr = (-(w.*r.^(3)-2*m)./(r.*(w.*r^(3)+4*m))).*f - (9*w^(2)*m^(2).*r)./((w^(2).*r.^(4)+4*w*m.*r).^(3/2));
I know the function f goes to infinity when r=0, so I can't use an initial condition where r=0. I instead want to use a condition where f=0 when r=r0, a value I've found. How do I input this? Every ODE solver seems to only allow a condition where r=0.

Answers (1)

Try
rspan = [0.01 1];

4 Comments

I have the rspan, but I need to insert something in the condition section. So my code for the solution is:
[r,f] = ode45(dfdr,rspan,f(r=r_0)=0)
the final part of the bracket is the initial condition, whch needs to be that f(r=r_0) = 0, but I'm not sure how to input that.
Put it like that. Im sure it will be correct
Doesn't that correspond to the condition f(r=0)=0? My function does not =0 when r=0, it equals 0 for a specific non-zero r.
That correspond for f(rrspan(1))=value
And only value has to be there
see ode45 help

Sign in to comment.

Tags

Asked:

on 4 Mar 2020

Commented:

on 7 Mar 2020

Community Treasure Hunt

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

Start Hunting!