フィルターのクリア

Gradient of Substituted Symbolic Variables

3 ビュー (過去 30 日間)
bh1910
bh1910 2015 年 7 月 25 日
編集済み: Walter Roberson 2015 年 7 月 25 日
Hello, I'm having a problem with finding the gradient of a substituted symbolic variable:
My code is:
syms x y z
f = x^2 + x + y^2 - y;
subs(f, y, z)
g = gradient(f, [x, z])
When I run it, the gradient turns out to be [2*x+1, 0]. It doesn't seem to calculate the z variable derivative. Does anyone know why?
Tks

採用された回答

bio lim
bio lim 2015 年 7 月 25 日
編集済み: bio lim 2015 年 7 月 25 日
It is because your function f is not updated. Here is what you need to do.
syms x y z
f = x^2 + x + y^2 - y;
f = subs(f,y,z);
g = gradient(f, [x,z])
The result is
g =
2*x + 1
2*z - 1
  2 件のコメント
bh1910
bh1910 2015 年 7 月 25 日
Tks a lot.
bio lim
bio lim 2015 年 7 月 25 日
My pleasure.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeNumber Theory についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by