plot quiver onto the base of a 3D plot

2 visualizaciones (últimos 30 días)
Gerard Nagle
Gerard Nagle el 21 de Jun. de 2019
Comentada: Star Strider el 24 de Jun. de 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

Respuesta aceptada

Star Strider
Star Strider el 21 de Jun. de 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:
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 comentarios
Gerard Nagle
Gerard Nagle el 24 de Jun. de 2019
Thanks Star Strider, brillant answer, much appreciated. Gerard
Star Strider
Star Strider el 24 de Jun. de 2019
As always, my pleasure!
I appreciate your compliment.
This was fun to solve!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Surface and Mesh Plots en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by