plot quiver onto the base of a 3D plot
14 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
Star Strider
2019-6-21
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 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Vector Fields 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!