# Solving a non-linear second order ODE with Matlab

25 views (last 30 days)
Whitewater on 29 Apr 2015
Commented: Jan on 30 Apr 2015
I am brand new to Matlab, but I have to find an approximate numerical solution to the following differential equation:
d^2p/dr^2+dp/dr*1/r-2*exp(m(r))*sinh(p)=0 OR p''+p'*(1/r)-2*exp(m(r))*sinh(p)=0
I have separated it (I think correctly??) into two first order ODEs:
y0'=y1 y1'=2*exp(m(r))*sinh(y1)
Now I am confused on how to input this into Matlab. Any help is greatly appreciated!
##### 0 CommentsShowHide -1 older comments

Sign in to comment.

### Accepted Answer

Torsten on 29 Apr 2015
Use UDE45 if your problem is an initial value Problem, use bvp4c if it is a boundary value problem.
Best wishes
Torsten.
##### 3 CommentsShowHide 2 older comments
Jan on 30 Apr 2015
@Torsten: You know that you can edit your messages?

Sign in to comment.

### More Answers (2)

Pratik Bajaria on 29 Apr 2015
Hello,
ode45 must work for you. All you have to do is make a function handle, which carries your ode function that you have split into set of first order differential equations and then use ode45 solver in MATLAB to attain a solution.
Similar to example shown on this URL: ODE45
Hope it helps!
Regards, Pratik
##### 0 CommentsShowHide -1 older comments

Sign in to comment.

Bjorn Gustavsson on 29 Apr 2015
Another pointer...
You have in fact not separated your DE correctly. You get y1' directly from your DE if you change dp/dr with y1.
HTH
##### 0 CommentsShowHide -1 older comments

Sign in to comment.

### Community Treasure Hunt

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

Start Hunting!