MATLAB: 3D interpolation using griddedInterpolant to train the interpolation function F with Spline method

griddedinterpolant

I have a training dataset and I want to perform a 3D interpolation using griddedInterpolant to train the interpolation function F with Spline method:
Can someone help me with creating this interpolation function?

Best Answer

Your data is not gridded, as can be seen from,
[x,y,v]=readvars(websave('data','https://www.mathworks.com/matlabcentral/answers/uploaded_files/547483/Training%20dataset.xlsx'));
scatter(x,y)
So, I'm not completely sure what you want. One way to fill in the missing data to make it gridded would be,
xg=unique(x); yg=unique(y);
S=scatteredInterpolant(x,y,v,'linear','none');
vg=S({xg,yg});
F=griddedInterpolant({xg,yg},vg,'spline');
surf(xg,yg,vg.','EdgeColor','none','FaceAlpha',0.4);
colormap cool
view(-75,35);