how to use ode45 with 4 ode?

2 views (last 30 days)
Shani Gal
Shani Gal on 14 Jan 2017
Answered: John D'Errico on 14 Jan 2017
Hi
I have a set of 4 ode, How can I use ode45 to solve them?
The ode:
dr/dt=u
d(TH)/dt=h/r^2
du/dt=h^2/r^3-1/r^2+a(t)*sin(phi)
dh/dt=r*a(t)*cos(phi)
I also know:
h=r^2*d(TH)/dt
a(t)=ASS/(BSS*t)
phi=phi1+atan(r*u/h)
( ASS, BSS, phi1 are constant)
( the variables are: r TH u h phi a(t) and t is the time )
Thank you
Shani

Answers (1)

John D'Errico
John D'Errico on 14 Jan 2017
Did you try it? Did you read the help for ODE45? There are examples in there.
You need to spend some time thinking about this problem.
You state that: "I also know:
h=r^2*d(TH)/dt
a(t)=ASS/(BSS*t)
phi=phi1+atan(r*u/h)
The first one is merely a restatement of one of the ODEs. So it is not relevant.
The second equation is just a reflection that a(t) is NOT an unknown. It is a linear function of t. So calling a(t) an unknown is silly.
Finally, the third equation is merely a relation between the other unknowns. So, given values for {phi1,r,u,h}, you can just replace phi anywhere you see it with that relation. So phi is also not an unknown in context of a differential equation solution.
That means you have 4 ODEs, with 4 variables to solve for: {r,TH,u,h}. Compute phi afterwards if you need it as a variable. But at that point, you have the values for all other variables at any time step.
Again, just read the doc for ODE45. Look at the examples in there, then just follow what you see.

Tags

Community Treasure Hunt

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

Start Hunting!