MATLAB: Using gridfit to compute data for a hill chart

contour plotgridfithill chartsurface smoothing

Hello everyone,
smoothing a surface with the gridfit function found on FEX here seemed to me like a good way to "clean" up data in order to generate a clear hill chart. However gridfit extrapolates the data to the grid boundries, so the generated contour plot doesnt really look like its supposed to.
Is there a way to still use the smoothing of gridfit without extrapolating to the grid boundries? For example, this first image shows the mesh generated using Matlabs own meshgrid and griddata functions.
The next image shows the result of using gridfit with the exact same inputs.
As you can see, the 2nd mesh is not useable for a contour plot. So is there a way to use gridfit without extrapolating to the edges of the grid nodes, only smoothing the existing x,y,z values? I'm still somewhat new to Matlab and maybe I've just used the inputs/options in a wrong way?
Thanks for your help!

Best Answer

Gridfit is designed to extrapolate, and to do so as smoothly as possible. That is how it is written, and you will not change it. There are no settings you can change in this matter. Sorry.
gridfit works on a rectangular lattice in the (x,y) plane. With a bit of programming expertise, you could triangulate that lattice, then carefully deal with those triangles that cross the convex hull. The result will be a new triangulation that lies entirely inside the convex hull of the data. It would take some work on your part though, and an understanding of how triangulations can be manipulated.
I can think of two other viable schemes to solve the problem. But if you insist on using a tool that will smooth the surface within the convex hull, then it will take some effort on your part.