plot quiver onto the base of a 3D plot

2 ビュー (過去 30 日間)
Gerard Nagle
Gerard Nagle 2019 年 6 月 21 日
コメント済み: Star Strider 2019 年 6 月 24 日
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

採用された回答

Star Strider
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:
plot quiver onto the base of a 3D plot - 2019 06 21.png
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:
plot quiver onto the base of a 3D plot (2) - 2019 06 21.png
  2 件のコメント
Gerard Nagle
Gerard Nagle 2019 年 6 月 24 日
Thanks Star Strider, brillant answer, much appreciated. Gerard
Star Strider
Star Strider 2019 年 6 月 24 日
As always, my pleasure!
I appreciate your compliment.
This was fun to solve!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSurface and Mesh Plots についてさらに検索

タグ

製品


リリース

R2019a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by