Derivative of a symbolic function with multiple dependent variables
3 ビュー (過去 30 日間)
古いコメントを表示
Gabriele Porcelli
2020 年 3 月 2 日
コメント済み: Gabriele Porcelli
2020 年 3 月 7 日
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?
0 件のコメント
採用された回答
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 Center および File Exchange で Symbolic Math Toolbox についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!