Derivative of a symbolic function with multiple dependent variables

8 次查看(过去 30 天)
Hello everybody. I'm facing this problem. I have a variable q(t) time dependent. I have to derive it in MatLab and I want to substitute numerical values to q(t), qd(t) but if I do that, as one can expect, the derivative of a number is 0 and then my function is constantly equal to 0. i write here an example:
syms q(t)
f = 2*q^2;
fd = diff(f,t)
subs(fd,q,5).
The result is 4*q(t)*diff(q(t), t).
So fd is function of q and qd and I want to substitute both with numerical numbers. Do you know any solution?

采纳的回答

Sai Sri Pathuri
Sai Sri Pathuri 2020-3-5
If you want to substitute values for q(t) and dq(t), you may fisrt substitute the value for dq(t) followed by the value for q(t). Let the value to be substituted for dq(t) be 2.
syms q(t)
f = 2*q^2;
fd = diff(f,t)
a = subs(fd,diff(q(t),t),2)
which gives an output
fd(t) = 4*q(t)*diff(q(t), t)
a(t) = 8*q(t)
Now, you may substitute the value of q(t) in a(t)
subs(a(t),q(t),5)
to get the ouput as
ans = 40

更多回答(0 个)

类别

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

产品


版本

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by