Plotting Gradient of a 3-variable Function
9 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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 Commenti
Risposte (1)
Torsten
il 10 Apr 2022
Modificato: Torsten
il 10 Apr 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 Commenti
Vedere anche
Categorie
Scopri di più su Calculus in Help Center e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!