How to vectorize or speed up ODE solver with vector ?
4 次查看(过去 30 天)
显示 更早的评论
I would like to vectorize or speed up ODE solver with vector E? This is extremely slow following this routine.
nTime = length(timespan);
y_list = zeros(nTime, length(y0));
y_list(1, :) = y0;
for iTime = 2:nTime
[t_, y_] = ode45(@yourFcn, timespan(iTime-1:iTime), y0, options, E(iTime));
y0 = y_(end, :);
y_list(iTime, :) = y0;
end
1 个评论
Daniel Armyr
2016-2-3
If I understand it correctly, you are calling ode45 in a loop and letting ode45 just compute a single step for each loop iteration.
As far as I can tell, your code does nothing that it could not do by a single call to ode45 and then extracting the data you want from the return vectors of ode45.
回答(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!