How can I use ode15s with a tspan of two elements?

2 visualizaciones (últimos 30 días)
Elia Paini
Elia Paini el 8 de Abr. de 2021
Comentada: Elia Paini el 8 de Abr. de 2021
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!

Respuesta aceptada

Jan
Jan el 8 de Abr. de 2021
Editada: Jan el 8 de Abr. de 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]);

Más respuestas (0)

Categorías

Más información sobre Ordinary Differential Equations en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by