Ode45 to solve nonlinear second order ode

Click For Summary
The discussion revolves around solving a nonlinear second-order differential equation using MATLAB's ode45 function. The user has derived two first-order ordinary differential equations (ODEs) from the original equations and is attempting to solve for the variable r at t=1, given specific initial conditions. They express confusion regarding the implementation of ode45, particularly in handling arrays and the syntax required for their specific problem. Suggestions include starting with simpler equations to build familiarity with the solver. The user seeks guidance on effectively using ode45 and finding relevant examples in the help files.
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.
 
Question: A clock's minute hand has length 4 and its hour hand has length 3. What is the distance between the tips at the moment when it is increasing most rapidly?(Putnam Exam Question) Answer: Making assumption that both the hands moves at constant angular velocities, the answer is ## \sqrt{7} .## But don't you think this assumption is somewhat doubtful and wrong?

Similar threads

Replies
4
Views
1K
  • · Replies 3 ·
Replies
3
Views
1K
Replies
3
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 2 ·
Replies
2
Views
1K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 14 ·
Replies
14
Views
1K
Replies
12
Views
2K
  • · Replies 6 ·
Replies
6
Views
2K
Replies
9
Views
2K