How to vectorize or speed up ODE solver with vector ?

조회 수: 5 (최근 30일)
Ole
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
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 CenterFile Exchange에서 Ordinary Differential Equations에 대해 자세히 알아보기

제품

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by