MATLAB Answers

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

조회 수: 23(최근 30일)
Jens Lindrup
Jens Lindrup 20 Mar 2020
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

댓글을 달려면 로그인하십시오.

답변(1개)

Christopher Creutzig
Christopher Creutzig 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

댓글을 달려면 로그인하십시오.

Community Treasure Hunt

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

Start Hunting!

Translated by