Ode45 to solve nonlinear second order ode

  • Thread starter sozener1
  • Start date
  • #1
19
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
View attachment 34339

View attachment 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??

Homework Statement





Homework Equations





The Attempt at a Solution

 

Answers and Replies

  • #2
hunt_mat
Homework Helper
1,741
25
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.
 

Related Threads on Ode45 to solve nonlinear second order ode

Replies
2
Views
453
  • Last Post
Replies
6
Views
1K
  • Last Post
Replies
3
Views
932
  • Last Post
Replies
1
Views
742
  • Last Post
2
Replies
33
Views
813
Replies
1
Views
3K
Replies
17
Views
2K
Replies
6
Views
11K
Replies
2
Views
425
Replies
2
Views
3K
Top