ode45 solver loop

4 次查看(过去 30 天)
Marco Sammito
Marco Sammito 2016-11-9
回答: Torsten 2016-11-9
Hi. I have to solve this equation
where h is defined by:
My idea is to initialize h=1, solve the first equation, calculate a new value for h:
and do this many times because it guarantees that h has converged. In the Run.m file I do not know how to express the second derivative of R, in fact MATLAB says that Rp is undefined.
Plesset.m file
function Rp = Plesset(t, R)
Rp = zeros(2, 1);
Rp(1) = R(2);
h = 1;
h = 1/R(1)*((R(2)/h)^(1/3) + R(2)/h);
Rp(2) = 1/R(1) * (-1.5 * (R(2))^2 + R(2)/h + sin(t));
Run.m file
for i = 1:100
[t, R] = ode45('Plesset', [0,5], [0,0]);
h = R(2)/(R(1)*Rp(2) + 3/2*(R(2))^2 - sin(t));
end
[t, R(:,1)]
plot(t, R(:,1))
Thank you.

回答(1 个)

Torsten
Torsten 2016-11-9
ODE15S can solve differential-algebraic problems. So just use it to solve the two differential equations for R and the algebraic equation for h simultaneously.
To see how this works, look up the section
Solve Robertson Problem as Semi-Explicit Differential Algebraic Equations (DAEs)
under
https://de.mathworks.com/help/matlab/math/solve-differential-algebraic-equations-daes.html
for an example.
Best wishes
Torsten.

类别

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