Solving a nonlinear ODE

17 次查看(过去 30 天)
abdullah al - jailawi
Hi all,
I am trying to use Matlab to solve the following equation obtain from the growth of a bubble with a liquid (fluid mechanics) where R is R(t):
R*Rdoubledot + ((3/2)(Rdot)^2) = Pgas/rhoo
With my two initial conditions at t=0 being:
R(t=0) = R0 and Rdot(t=0) = 0
I have basic experience with Matlab, and I only know that I need to use the syntax [t,y] = ode45(odefun , tspan, y0) to solve the given problem.
I would really appreciate any help you guys can offer with this script.
Thank you,
AJ

回答(1 个)

James Tursa
James Tursa 2020-9-26
编辑:James Tursa 2020-9-26
Step 1: Solve your ODE for the highest order derivative, in this case Rdoubledot (on paper)
Rdoubledot = stuff (you figure this out with simple algebra)
Step 2: Rewrite your ODE as a system of 1st order ODE's (on paper)
In your case you have a 2nd order ODE, so your state vector will be two elements. Call it R:
R(1) = R
R(2) = Rdot
Step 3: FIgure out the equations for the derivatives of Step 3 (on paper)
RDOT(1) = R(2); % this one is easy
RDOT(2) = some expression involving R(1) and R(2) obtained from Step 1 with appropriate substitutions
Step 4: Generate the function handle that you will feed to ode45 (actual code)
odefun = @(t,R) some expression involving t, R(1), R(2)
In this case, the expression needs to be a 2-element column vector using the RDOT stuff from Step 3
Also, the variables Pgas and rhoo will be part of this expression (you need to define them first before generating odefun)
Step 5: Generate the initial condition variable (actual code)
Since you have a two element state, this will be a two element column vector
R0 = [initial R value; initial Rdot value]; % you fill in these values
Step 6: Feed the odefun, R0, and time span to ode45 (actual code)
Give all this a try and come back with any questions you still have. The doc for ode45 gives an example of a 2nd order ODE, so you might look at that.

类别

Help CenterFile Exchange 中查找有关 Ordinary Differential Equations 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by