Turn variable-step solution into fixed-step
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Viggo Wivestad
le 22 Sep 2016
Réponse apportée : Star Strider
le 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 commentaires
Réponse acceptée
Star Strider
le 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 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Ordinary Differential Equations dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!