Symbolic: remove time dependency of variables or take derivative wrt time dependent variable

28 次查看(过去 30 天)
I have several functions with time dependent variables. How do I change the functions so they are no longer time dependent? So for instance, I want to define the following:
syms alpha(t)
x = sin(alpha(t))
x_dot = diff(x,t)
Now I want to take the derrivative of x wrt alpha, but that is not possible, because alpha is time dependent - so I tried using the subs command
syms alpha
x_dot = subs(x_dot,alpha(t),alpha)
diff(x_dot,alpha)
This does, however produce an error. Is there any workaround to this?
Thank you very much in advance. Best regards Jens

回答(1 个)

Christopher Creutzig
With your line syms alpha, you have overwritten the previous value of the MATLAB(!) variable alpha, so the alpha(t) in your subs call no longer does what you expected it to do.
You could substitute alpha(t) with a new variable like this:
syms alpha(t)
x = sin(alpha(t))
x_dot = diff(x,t)
syms alpha_t
x_dot = subs(x_dot,alpha(t),alpha_t)
diff(x_dot, alpha_t)
But I doubt that is what you want, since x_dot contains a diff(alpha(t),t) term and if you now make alpha independent of t, that gives 0. I have to guess, but maybe you want this?
syms alpha(t)
x = sin(alpha(t))
x_dot = diff(x,t)
syms alpha_t alpha_dot
x_dot = subs(x_dot, diff(alpha(t),t), alpha_dot)
x_dot = subs(x_dot,alpha(t),alpha_t)
diff(x_dot, alpha_t)

类别

Help CenterFile Exchange 中查找有关 Assumptions 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by