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

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?

 采纳的回答

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);

3 个评论

Thank you Matt J for your reply.
Indeed, what I want to do is finding an interpolation function for my training dataset with linear and spline methods. Then I will test these interpolation functions with another test dataset that I have.
For the linear interpolation, I can use ScatteredInterpolant. I'm trying to use griddedInterpolant for cubic spline but I cannot figure out how to use my tarining dataset since it is not gridded.
I see that you first used scatteredInterpolant and then griddedInterpolant with spline. It means that you first interpolated linearly and then interpolated with spline. As my dataset is smooth, do you think I can do the same?
Yes I do. I was not so sure whether this is the right procedure.
Thank you!

请先登录,再进行评论。

更多回答(0 个)

类别

在 帮助中心 和 File Exchange 中查找有关 Interpolation 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by