I found that if I use the griddatamethod with the Cubicinterpolation method to determine the value x, yit will return NaN. One report says that this is because the data xand yare very close to the convex hull.
Any idea how to fix this?
Edit: Please note: I cannot make sure that my inputs are monotonically increasing (thus gridfit is not working). The reason is that I would need to stitch my region (which may be an irregular polygon in 2D), get all the points before generating the corresponding values Zfor each point. My code is as follows:
function ZI=Interpolate3D(scatteredData, boundary)
%scatteredData is the scattered points, boundary is the area that I want to generate 3D surface.
% Given the boundaries, generate mesh first
[element,points]= GenMesh(boundary);
ZI = griddata(scatteredData(:,1),scatteredData(:,2),scatteredData(:,3),points(:,1),points(:,2), 'cubic',{'QJ'});