Plotting Gradient of a 3-variable Function
9 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I am trying to plot the gradient of a 3-variable function (the functions are all syms).
g = gradient (f, [AB, BC, AC])
I know the code for a two-variable looks like this:
[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)
How can I modify the code to be able to plot the 3-variable gradient?
0 comentarios
Respuestas (1)
Torsten
el 10 de Abr. de 2022
Editada: Torsten
el 10 de Abr. de 2022
Depends on what you want to plot.
In each point (x,y,z), the gradient g=(gx,gy,gz) is a 3d-vector associated with this point.
But plotting 3d vectors attached to points in 3d-space won't give a reasonable plot in my opinion.
So without fixing a plane in which you want to see the gradient and maybe projecting the gradient onto this plane, you won't be able to visualize anything.
So you will first have to decide where and what you want to plot.
If you want to try a 3d-vector plot, use quiver3:
0 comentarios
Ver también
Categorías
Más información sobre Calculus en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!