MATLAB: Plot quiver onto the base of a 3D plot

MATLABplot3quiver

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

Best Answer

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