Borrar filtros
Borrar filtros

Getting the accelerations (or 2nd time derivative) from ODE solver

25 visualizaciones (últimos 30 días)
Hi guys, My name is Pedro Calorio and I'm an engineering student who works with vehicle dynamics.
My question is rather basic, but I'm still stuck to it. Who do I get the accelerations from the ode solvers? I know that the ode family of MATLAB cannot handle 2nd order equations, so the solution to it is to broke a 2nd order system into 1st order by adding variables. But when I create a function with my two equations that are a 1st order equation, when I call the ode solver to solve it, I get the displacement and velocities, but not the acceleration.
The solution to this that I came up with was to apply diff() function into the velocities that I got from the ODE solver to get the accelerations. But it doesn't feel right and I believe there is a better way for dealing with this.
Can anybody help me with this?
  1 comentario
Pedro Calorio
Pedro Calorio el 9 de Mzo. de 2021
An code example to illustrate what I'm talking about..
function dx = solveEoM(t,x)
displacement = x(1)
velocity = x(2)
...some code here...
dx(1) = x(2);
dx(2) = Force/Mass;
end
When I call the ode solver to solve this function "solveEoM", I get as a result the displacement and the velocities, but not the accelerations

Iniciar sesión para comentar.

Respuesta aceptada

Cris LaPierre
Cris LaPierre el 9 de Mzo. de 2021
The ode solvers in MATLAB solve the odes. The solution of a dv/dt equation is velocity. If you want the solver to return acceleration, you need to supply it with an equation for the derivative of acceleration, da/dt, which would be .
An alternative approach is to take the difference of the returned velocities and divide by the corresponding difference in time
a = diff(velocity)/diff(time)
  2 comentarios
Pedro Calorio
Pedro Calorio el 10 de Mzo. de 2021
Thanks for your awnser, Cris
Why can't I use:
a = diff(velocity,1)
Why do I need to differentiate the time as well?
Also, in that case, it wouldn't be possible to formulate a equation of 3rd order to get the accelerations d^2x/dt^2 from the ode solver, right? Like a function "get_accelerations"?
Cris LaPierre
Cris LaPierre el 10 de Mzo. de 2021
In this use case, diff is taking the differnece between neighboring elements in your vectors. It comes down to what acceleration is - the change in velocity per time. If you leave out the time, you will just be getting the change in velocity between each element, and not the rate of change.
If your acceleration is not constant, then there is third order equation that defines the rate of change in acceleration.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

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

Community Treasure Hunt

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

Start Hunting!

Translated by