MATLAB Answers

Ole
0

How to vectorize or speed up ODE solver with vector ?

Ole
さんによって質問されました 2016 年 1 月 30 日
最新アクティビティ Daniel Armyr さんによって コメントされました 2016 年 2 月 3 日
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.

サインイン to comment.

製品

0 件の回答


Translated by