MATLAB Answers

Symbolic differentiation with respect to first derivative

4 ビュー (過去 30 日間)
madhan ravi
madhan ravi 2019 年 12 月 28 日
編集済み: madhan ravi 2019 年 12 月 28 日
Is it possible to make a derivative of an equation with respective to the first derivative . Illustration:
syms x(t)
eqn = diff(x) - 2
The expected result is 1 [edited after sir Walters answer] . A workaround is using subs() but is there any other straightforward way to achieve the result?

  0 件のコメント

サインイン to comment.


Walter Roberson
Walter Roberson 2019 年 12 月 28 日 is the only available tool provided by Mathworks.
However, this is not going to do what you want:
syms x(t); dx = diff(x); eqn = dx - 2;
>> diff(eqn,dx)
Error using sym/diff (line 26)
Arguments, except for the first, must not be symbolic functions.
(which is a misleading error message that I will file a bug about.)
Note that if you would to have
eqn = x - 2
diff(eqn, x)
the result would be 1, not -2 . -2 is constant with respect to x(t) or diff(x,t) so it is going to vanish in the derivative.
It is tempting to use something like to substitute the derivative with a symbol that you can then differentiate with respect to. However, drivatives are not independent of the original function, and you can arrive at wrong answers if you do this. I have posted examples in the past demonstrating that differentiating with one function with respect to another by processes like this give incorrect solutions (but that was a while ago and might be a bit tricky to locate now.) You cannot generally differentiate with respect to a function using normal calculus: you need The Calculus of Variations, which MATLAB does not implement.

  1 件のコメント

madhan ravi
madhan ravi 2019 年 12 月 28 日
Ah my bad it’s 1 , just made a mistake there . Thank you very much for all the explanations sir Walter:) it covered everything what I was hoping for.

サインイン to comment.

その他の回答 (0 件)

サインイン してこの質問に回答します。




Translated by