The code from the M file will not complete
8 views (last 30 days)
Show older comments
When I run the code, which I received from my colleagues and which performs the calculation according to the Runge–Kutta–Fehlberg method (the method uses a variable integration step), the situation is such that the code cannot be completed.
The only thing I noticed is that the problem is in the last while loop.
When I remove the last while loop, the code completes successfully.
It does not matter what input value you enter for the parameter "a".
The controversial while loop is marked in the M file.
Please help
0 Comments
Answers (1)
Abhinav Aravindan
on 2 Dec 2024
After looking through your code, it seems that the issue is due to the last "while" loop in Line 352, as pointed out in your query. The issue is that for the breaking condition of the "while" loop to be met, the value of "Le(q)" must be greater than "Lrange(2)". However, after the first few iterations, the value of "Le(q)" and "q" are not updated as the following "if" condition in your code is not satisfied, since the value of "gres_v" and "H" is above the set tolerance:
if gres_v<tol && gres_T<tol || H<2*Hmin
v(q+1)=v_II;
T(q+1)=T_II;
if Lq+H>br1
Le(q+1)=Lrange(2);
else
Le(q+1)=Lq+H;
end
P(q+1)=f*omega*(1-(v_II/V_gr)^2)/(s*(L_1+Le(q+1)));
q=q+1;
Lq=Le(q);
end
As a result, the loop keeps running indefinitely, and the program never completes. To resolve this, you may look into the above snippet from your code (Line 394) to address the update issue for "Le(q)".
Additionally, you may refer to following File Exchange submissions on "Runge-Kutta-Fehlberg" which may be helpful:
0 Comments
See Also
Categories
Find more on Software Development Tools 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!