ode solver , restart from where the simulation ended

조회 수: 6 (최근 30일)
Deepa Maheshvare
Deepa Maheshvare 2020년 2월 28일
편집: Deepa Maheshvare 2020년 2월 28일
Hi,
I am using ode solver to simulate a system of differential equations.
tspan = 0:0.0001:1
[t s] = ode15s(@(t,s) fun(t,s), tspan , s0 ,options);
I ran for the tspan that is defined and obtained the results (0 to 1 second). I want to restart the simulation from where it ended and run for 2 seconds instead of rerunning the whole simulation again.
Any suggestions?
Thanks

채택된 답변

Bjorn Gustavsson
Bjorn Gustavsson 2020년 2월 28일
Just extract the solution at 1 s from s (i.e. the last row in s). Then simly run the integration from there:
t2 = linspace(1,3,2001); % or what resoution you need
s0_2 = s(end,:); %
[t1to3 s1to3] = ode15s(@(t,s) fun(t,s), t2 , s0_2 ,options);
That should be enough.
HTH

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Programming에 대해 자세히 알아보기

제품


릴리스

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by