How do I generate a 3D Surface where the X and Y coordinates are bounded by a hexagon instead of just the cartesian axes?

I have a 3D surface that I am trying to plot, which is described by z as a function of x and y. I defined my x and y coordinates using meshgrid, but I need to only plot the surface within a regular hexagon. I tried creating a meshgrid and only defining my function on the z axis for values of x and y that are within the lines bounding the edges of the hexagon, but this fills in zeros for the remaining values of z, and makes the surface hard to see.
How do I just plot the 3D surface within the hexagon?

More Answers (0)

Community Treasure Hunt

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

Start Hunting!