Turn variable-step solution into fixed-step
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Viggo Wivestad
am 22 Sep. 2016
Beantwortet: Star Strider
am 22 Sep. 2016
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 Kommentare
Akzeptierte Antwort
Star Strider
am 22 Sep. 2016
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 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Ordinary Differential Equations finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!