syms dependent on time with dots

28 visualizaciones (últimos 30 días)
Tobias
Tobias el 9 de Oct. de 2020
Comentada: Tobias el 9 de Oct. de 2020
Hello,
I have a question. I want to implement the time derivative of u in the following way in Matlab:
syms theta t
syms phi t
u = 5*cos(theta)+phi
u_dot = diff(u,t);
When I execute this code, I end up with u_dot = 0, which is not what I want.
Does someone maybe know how to get the u_dot in the above form?
Thanks in advance!

Respuestas (1)

KSSV
KSSV el 9 de Oct. de 2020
syms A theta(t) phi(t) ;
u = A*cos(theta)+phi
du = diff(u,t)
  1 comentario
Tobias
Tobias el 9 de Oct. de 2020
Thank you for your help!
Yes this is what I wanted. I just had to use the syms function once.
But in my real code, u is a vector. It has the same structure as in this example:
syms A theta(t) phi(t);
u = [A*cos(phi)*theta;sin(phi)*phi];
du = diff(u,t);
Now u and du are converted to 1x1 symfun functions, but I actually want it to be a vector output as well.
I got this output for du:
A*cos(phi(t))*diff(theta(t), t) - A*sin(phi(t))*theta(t)*diff(phi(t), t)
sin(phi(t))*diff(phi(t), t) + cos(phi(t))*phi(t)*diff(phi(t), t)
But I want the output to be in 2x1 vector form. Do you maybe know how to do this?
Thanks!

Iniciar sesión para comentar.

Categorías

Más información sobre Symbolic Math Toolbox en Help Center y File Exchange.

Productos


Versión

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by