필터 지우기
필터 지우기

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 CenterFile Exchange에서 Number Theory에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by