How to saturate a variable in ODE solver ?

5 visualizaciones (últimos 30 días)
Vincent DUFOUR
Vincent DUFOUR el 15 de Mzo. de 2017
Comentada: Vincent DUFOUR el 16 de Mzo. de 2017
Hi everyone,
I am currently using ode15s to solve a ODE system and I would need to saturate a variable directly in the dynamic, is it possible ?
To make it clear, I am resolving the following system:
if true
p-dot-dot=(1/M)*wRb*F1*u+f
w_dot = inv(J)*F2*u+g
end
wRb, J , F1 and F2 are matrices, f and g other terms and I would need to prevent my "u" variable from being more than a threshold.
I already tried to do this:
for i=1:length(u)
if u(i)>800^2
u(i)=800^2;
end
end
just after the computation of u and before computing p_dot_dot and w_dot, unfortunately it doesn't seem to work...
Thanks in advance
  16 comentarios
Torsten
Torsten el 15 de Mzo. de 2017
You compare the u-components to 640000, not 800.
Best wishes
Torsten.
Vincent DUFOUR
Vincent DUFOUR el 16 de Mzo. de 2017
All right guys to conclude the topic I actually realized that I was using the wrong data... I was extracting the 'u' through dX=u but it logically made the sum over the time which doesn't mean anything for me here...
The saturation actually works !
Thanks all of you for your time and help
Cheers

Iniciar sesión para comentar.

Respuestas (1)

Jan
Jan el 15 de Mzo. de 2017
Matlab's ODE integrators are designed to handle functions with a ontinuous derivative. Functions like max, min, if, abs etc. makes the output non-smooth and in consequence they should not appear inside the function to be integrated. The resulting discontinuities confuse the step size control. The results beein used to calculate one step can be coming from intervals with different definitions for "u". If you are lucky you get an error message, but without luck Matlab squeezes the stepsize until the rounding error dominates the final value and the trajectory is more or less random.
Please do not post "doesn't seem to work..." without providing any details. My answer is based on guessing what going wrong.
  4 comentarios
Vincent DUFOUR
Vincent DUFOUR el 15 de Mzo. de 2017
Ok thanks I'll see in this direction, btw I uploaded my files to be run if you want to see.
To make it quick, it's the ODE system of a six-rotor drone, u=wi^2 and wi are the rotation speed of the propeller which I want to be constrained (<800rad/s), the p_dot_dot is the acceleration in position and w_dot in rotation.
In this case I want my drone to follow a sinus trajectory on pitch and roll, while all the other (x,y,z and yaw) remain at 0.
Thanks a lot for all your answers
Vincent DUFOUR
Vincent DUFOUR el 15 de Mzo. de 2017
Other question for Jan, is it possible to set an event on my variable 'u' which is not my state x ?
I saw that to use the Event option of odeset the function will have the form [val,isterminal,direction] = myEventFcn( t,x) but I need an event on my 'u' not x.. don't know if it's possible

Iniciar sesión para comentar.

Categorías

Más información sobre Programming 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