ode45 solver loop

조회 수: 6 (최근 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