Modify ode45 so that the solution is always normed to 1
1 次查看(过去 30 天)
显示 更早的评论
Dear all,
I have a three-dimensional ode which I'd like to solve using a 4th order Runge-Kutta method, but I'd like the solution to always be normed:
y1(t)²+y2(t)²+y3(t)² = 1, for all t.
This is not the case when I use ode45 despite the fact that it should be from analytical study of the ode. How can I enforce such a constraint by modifying the ode45.m file (or by any other means)?
Thank you.
Edit :
I tried to modify the file ode45.m in MATLAB/R2012a/toolbox/matlab/funfun/ by setting ynew = ynew/norm(ynew) on line 274, but for some reason, it seems that editing this file doesn't change the solution I get, even if I set, say, ynew = 0, and after having restarted Matlab. Is there something more to do so that Matlab accept the changes?
0 个评论
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Ordinary Differential Equations 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!