필터 지우기
필터 지우기

Plotting Gradient of Multivariable function.

조회 수: 1 (최근 30일)
NISHANTH M P
NISHANTH M P 2021년 10월 8일
답변: Tanmay Das 2021년 10월 14일
I am Trying to Plot Grad of This Multimaviable Funtion...
the Chunk of My code as follows,
syms x y
f(x,y)=exp(-x.^2)+exp(-y.^2);
g=gradient(f,[x,y]);
disp(g);
[X, Y] = meshgrid(-1:.1:1,-1:.1:1);
G1 = subs(g(1),[x y],{X,Y});
G2 = subs(g(2),[x y],{X,Y});
quiver(X,Y,G1,G2)
my error is : "Error using symfun/subsref (line 172)
Symbolic function expected 2 input arguments but received 1.
Error in Untitled (line 14)
G1 = subs(g(1),[x y],{X,Y});"
please HElp me with this....

답변 (1개)

Tanmay Das
Tanmay Das 2021년 10월 14일
Hi Nishanth,
You can make multiple substitution using subs function in either of the two ways given below:
1) Make multiple substitutions by specifying the old and new values as vectors.
G1 = subs(g(1),[x,y],[X,Y]);
2) Alternatively, for multiple substitutions, use cell arrays.
G1 = subs(g(1),{x,y},{X,Y});

카테고리

Help CenterFile Exchange에서 Symbolic Math Toolbox에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by