ode45 solver loop
1 view (last 30 days)
Show older comments
Hi. I have to solve this equation
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/157838/image.png)
where h is defined by:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/157839/image.png)
My idea is to initialize h=1, solve the first equation, calculate a new value for h:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/157840/image.png)
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.
0 Comments
Answers (1)
Torsten
on 9 Nov 2016
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.
0 Comments
See Also
Categories
Find more on Ordinary Differential Equations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!