Best way to solve differential algebraic equations?

1 visualización (últimos 30 días)
Hello, I went through the pendulum example about solving differential algebraic equations. The system in the example is an autonomous system. For my application I have to solve an actuated system, so for the purpose of learning, I tried to modify the pendulum system so that it is actuated. To make it simple, I just made the pole radius r time variable (r -> r(t) = 1/10*(cos(t)+1) + 3). This is in line 44 in my code. The problem is, that decic gives me an error "Index exceeds matrix dimensions."
Can someone tell me how I can include a time dependent actuation function in a way, so I can change the function easily? Preferrably, I only want to have to change r(t) = 1/10*(cos(t)+1) + 3 to something else without having to change anything else in the code.
Thank you and regards.
  5 comentarios
Matthias Scheuerer
Matthias Scheuerer el 14 de Mzo. de 2018
Hi Torsten, I tried your suggestion, but the error is still the same. Actually the state vector (after all the previous modifications) is
DAEvars = [x(t); y(t); T(t); Dxt(t); Dyt(t); Dytt(t); Dxtt(t)],
so it contains 7 elements, hence 7 intial values should be enough, right? The system of equations also contains 7 equations.
Torsten
Torsten el 14 de Mzo. de 2018
The "dirty" method is to use the old code, remove r from the syms variables and replace "r" in equations eqn1 - eqn3 by "1/10*(cos(t)+1) + 3".

Iniciar sesión para comentar.

Respuesta aceptada

Matthias Scheuerer
Matthias Scheuerer el 16 de Mzo. de 2018
Matlab Support told me the solution: The problem is, that r(t) is a symbolic function, so r(0) returns a symbolic number. I used r(0) in the expression for a guess for inital values. This causes decic to throw an error, because it can only handle numerical inputs. So I had to cast y0est into double (double(y0est)) and it works. However, "Index exceeds matrix dimensions." is not a very suitable error message in this case.

Más respuestas (1)

Matthias Scheuerer
Matthias Scheuerer el 14 de Mzo. de 2018
Hi Birdman, thank you for your suggestion. r(t) is already a symbolic expression in my script. I subsitute it with the expression above, so there is t as a symbolic variable left. But it still produces the error I described above.
I attached the code as ASCII file.

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by