plot quiver onto the base of a 3D plot
14 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Gerard Nagle
le 21 Juin 2019
Commenté : Star Strider
le 24 Juin 2019
hi there,
I'm was looking at an issue on gradient, and I came across an example of a great plot in wikipedia. this is the link to it here https://en.wikipedia.org/wiki/Gradient and direct to plot working towards
I can get to a point, by using the following code, but I cant seem to find how I can shift or move or plot the quiver plot onto the base of 3d plot. ie, the quiver plot would be on the xy axis at a z value of -4.
I've found that contour has a handle handle called ContourZLevel property is a hidden property at https://undocumentedmatlab.com/blog/customizing-contour-plots-part-2 but I dont see such functionality with quiver.
any help appreciated.
many thanks
[x,y] = meshgrid(-80:80, -80:80);
z = -(cosd(x).^2 + cosd(y).^2).^2;
plot3(x,y,z)
grid
% planeimg = min(z,[],"all")
[xx,yy] = meshgrid(-80:10:80, -80:10:80);
zz = -(cosd(xx).^2 + cosd(yy).^2).^2;
[U,V] = gradient(zz);
hold on
h = quiver(xx,yy,U,V);
hold off
0 commentaires
Réponse acceptée
Star Strider
le 21 Juin 2019
This seems to approximate what I believe you want:
[x,y] = meshgrid(-80:80, -80:80);
z = -(cosd(x).^2 + cosd(y).^2).^2;
mesh(x,y,z)
grid
[xx,yy] = meshgrid(-80:10:80, -80:10:80);
zz = -(cosd(xx).^2 + cosd(yy).^2).^2;
[U,V] = gradient(zz);
hold on
h = quiver3(xx,yy,ones(size(zz))*min(zlim),U,V,zeros(size(zz)));
hold off
grid on
view(-30,30)
producing:
To plot it along the surface itself:
[x,y] = meshgrid(-80:80, -80:80);
z = -(cosd(x).^2 + cosd(y).^2).^2;
mesh(x,y,z)
grid
[xx,yy] = meshgrid(-80:10:80, -80:10:80);
zz = -(cosd(xx).^2 + cosd(yy).^2).^2;
[U,V,W] = surfnorm(xx,yy,zz); % Calculate Surface Normals
dW = gradient(W); % Gradient Of ‘W’
hold on
h = quiver3(xx,yy,zz,U,V,dW);
hold off
grid on
view(-30,60)
(There may be better mathematical expressions for the same idea.)
producing:
2 commentaires
Star Strider
le 24 Juin 2019
As always, my pleasure!
I appreciate your compliment.
This was fun to solve!
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Vector Fields dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!