Ode45 to solve nonlinear second order ode

Join the discussion
Ask a follow-up here, or get your own question answered by working scientists, mathematicians and engineers — people, not an autocomplete.
Real named experts · corrections over time · the nuance an AI answer skips
1 reply · 5K views
sozener1
Messages
19
Reaction score
0

Homework Statement



I'm given two equations

first
(d^2)*r/dt^2 - r((d*theta/dt)^2)= (-A)/r^2 --- this is a non linear second order differential equation

second
(r^2)*((d*theta)/dt)=B

B and A are just constants 1 and 10

from these two equations I obtained three first order odes so that you can use the ode45 in matlab

hopefully you can obtain it as well as its really difficult for me to type the equation with a computer and hopefully you can view the attachments which are the two given equations, for easier viewing
https://www.physicsforums.com/attachments/34339

https://www.physicsforums.com/attachments/34340

I've found d*theta/dt from second equation and substituted it into the first equation and found two first order odes

I have to solve these equations for r when t=1

I'm also given initial conditions r(0)=1, theta(0)=0, (dr/dt)(0)=0

I need to use ode45 in MATLAB to solve this problem and plot it to find r at t=1

and I also need to solve for theta simultaneously using ode45

so far I just getting a whole lot of errors

first of all I wrote a function

and then did something like [t,r]=ode45(@function, timespan, initialcondition) and it just doesn't seem to work out

I know how to use ode45 when I have something like dy/dt=-k*y/t with some initial condition

but with this problem I'm confused I think I'm supposed to use arrays or something

I need to expand my understanding of using ode45 solver so can anyone help me with this??
 
Physics news on Phys.org
Is there not an example in the help files?

One way to start is with a really simple set of equations and get that working, yes you will have to use arrays but this can be figured out with a bit of trial an error.