In Ode15s, how do I break the time span into smaller intervals and call the solver twice, so that the integration proceeds faster?
조회 수: 1 (최근 30일)
이전 댓글 표시
Hi, can anyone explain these lines from the Matlab website to me?
![微信图片_20190227145055.png](https://www.mathworks.com/matlabcentral/answers/uploaded_files/206063/%E5%BE%AE%E4%BF%A1%E5%9B%BE%E7%89%87_20190227145055.png)
and
![微信图片_20190227144909.png](https://www.mathworks.com/matlabcentral/answers/uploaded_files/206064/%E5%BE%AE%E4%BF%A1%E5%9B%BE%E7%89%87_20190227144909.png)
I understand how splitting the total time span into small intervals can speed up ODE. But in order to implement this method, how exactly do I "call the solver twice"? How to combine the outputs from each call into one? Say my total time span is
tspan=[t0 tf];
and I break it into
tspan1=[t0 t1];
tspan2=[t1 tf];
If I directly call the solver twice like the following,
% Method 1
[ta,y1]=ode15s(@odefun,tspan1,initialCond,solverOptions,additionalParams);
[tb,y2]=ode15s(@odefun,tspan2,initialCond,solverOptions,additionalParams);
I will get two outputs. But all I need is just one, like the [t, y] below.
% Method 2
[t,y]=ode15s(@odefun,tspan,initialCond,solverOptions,additionalParams);
How can I combine the results from method 1 and get only one output? It would be best if there's code or examples. Thank you.
댓글 수: 0
답변 (1개)
Torsten
2019년 2월 27일
tspan1=[t0 t1];
[ta,y1]=ode15s(@odefun,tspan1,initialCond,solverOptions,additionalParams);
initialCond=y1(end,:);
tspan2=[t1 tf];
[tb,y2]=ode15s(@odefun,tspan2,initialCond,solverOptions,additionalParams);
t=[ta(1:end-1);tb];
y=[y1(1:end-1,:);y2];
댓글 수: 3
참고 항목
카테고리
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!