se me pidió calcular el vector gradiente de una función introducida por el usuario SIN USAR EN COMANDO GRADIENTE, esto es lo que tengo, tambien añadí la opción de graficar
I was asked to calculate the gradient vector of a function entered by the user WITHOUT USING THE GRADIENT COMMAND. This is what I have, but is wrong I also added how to grap
4 views (last 30 days)
Show older comments
f = input('enter function ','s');
sf = str2sym(f);
v = symvar(sf);
g = diff(sf,v);
[x,y] = meshgrid(-5:0.2:5,-5:0.2:5);
u=eval(g(1));
v=eval(g(2));
quiver3(x,y,u,v)
8 Comments
Walter Roberson
on 17 Feb 2022
What is the idea behind doing the
syms v
??
Consider instead doing diff(sf, v(1)) and diff(sf, v(2)) as two calls.
Answers (0)
See Also
Categories
Find more on Calculus in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!