How to write ode45 to solve differential equations with changing parameters

3 visualizaciones (últimos 30 días)
Tao
Tao el 6 de Abr. de 2015
Comentada: Tao el 7 de Abr. de 2015
I am going to solve the differential equations:
dX = f(X, U, P), X is system states, U is control inputs which is known, and P is function of X, U and P itself. Since nonlinearity, P cannot be expressed analytically.
I tried to use ode45, but I have to use a for-end loop to upgrade my P for every step. Is there anyway I can avoid using for-end loop here? For example, just use ode45 to integrate my equations for one go?
I'm new to MATLAB, I will be very thankful if you let me know how to write it in detail. Thank you very much.
  2 comentarios
Torsten
Torsten el 7 de Abr. de 2015
dX=f(X,U,P) P-f2(X,U,P)=0
This is a differential-algebraic system which can be solved by ODE15S, e.g.
Best wishes
Torsten.
Tao
Tao el 7 de Abr. de 2015
I will first have a look on ode15s, then I will reply to you, probably with some questions, thank you.

Iniciar sesión para comentar.

Respuestas (1)

Jan
Jan el 6 de Abr. de 2015
Please explain the values of U and P with details. Is the function to be integrated still smooth? Otherwise ODE45 cannot handle it reliably. See http://www.mathworks.com/matlabcentral/answers/59582#answer_72047
  1 comentario
Tao
Tao el 7 de Abr. de 2015
U is continuous input series with respect to time, P is actually the force which depends on many other factors as I mentioned, I can put P in detail here but it will be TOO much. In short, P depends on X, U and itself, the equations are quite nonlinear. The function is the equations of motion of a car, I think it's smooth essentially. I didn't force the time step for ode45, the reason why I used ode45 with a for-end loop is to approximate this nonlinear system (equation of motion) to a ordinary differential equation, thus for example, between 0s to 0.001 second, the P is fixed, and ode45 can solve this equation, then between 0.001 second to 0.002 second, I re-calculate P, and use ode45 to solve the ordinary differential equations again (but the initial condition for this step comes from the end state of last step). Do you think this is a proper way to use ode45 with P changing? Thanks a lot.

Iniciar sesión para comentar.

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