Turn variable-step solution into fixed-step
2 ビュー (過去 30 日間)
古いコメントを表示
I am simulating a system that is very stiff and nonlinear using ODE23s. I need the variable step-length for the simulation to be stable. After the simulation I m going to analyse the dynamics of the system in a different program, and I need all my simulations to have the same length. Anyone has any experience making the simulation output uniformly sampled? Is this some setting in the ODE-solver or could I possibly use interp1?
0 件のコメント
採用された回答
Star Strider
2016 年 9 月 22 日
The ODE solvers are adaptive, but if you want all the results to have the same row length, you can specify the ‘tspan’ argument to have a specific length. The ODE solvers will output the closest results to the desired ‘tspan’ values that it estimates. You will not need to interpolate the results:
t0 = ...; % Start Time
tf = ...; % End Time
N = ...; % Number Of Time Values (Row Length Of Results)
tspan = linspace(t0, tf, N);
ic = [...]; % Initial Conditions Vector
[t,y] = ode45(@odefun, tspan, ic);
You can use the same construction to integrate all your ODE functions.
0 件のコメント
その他の回答 (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!