Symbolic: remove time dependency of variables or take derivative wrt time dependent variable
18 views (last 30 days)
Show older comments
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
0 Comments
Answers (1)
Christopher Creutzig
on 25 Mar 2020
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)
0 Comments
See Also
Categories
Find more on Symbolic Math Toolbox in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!