How can I use ode15s with a tspan of two elements?
4 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hi, I'm using the function ode15s to solve ODE. I don't understand why, with a vector of time with only 2 elements, Matlab automatically chooses the integration step.
If I insert a vector of at least 3 elements, as I expect to see, Matlab returns a vector of the simulated time with the same length. On the contrary, it doesn't happen with a vector of 2 elements.
How can I correct this problem, in order to solve an ODE with only 2 elements in tspan?
Thank you!
0 commentaires
Réponse acceptée
Jan
le 8 Avr 2021
Modifié(e) : Jan
le 8 Avr 2021
Why do you assume, that this is a problem?
With applying a tspan vectors with >= 3 elements, the integrators of Matlab perform an interpolation or adjust the step size until the specified time points are reached. But even then the intermediate step sizes are taken according to the step size control. Only the output is adjusted such, that t = tspan.
You can emulate this easily if you need the first and the last value only:
[t, y] = ode15s(...)
t = t([1, end]);
y = y(:, [1, end]);
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!