Data fitting using thin-plate spline/interpolation
Show older comments
I have several points in 3D space. I have used the surface fitting function to create a pretty accurate representation.
Now I need to generate an equation with the corresponding coefficients for this surface, so that I can use it elsewhere without having the original data points.
1) What is the equation for the thin-plate interpolation? Like when you use polynomial, sine, fourier, etc, there is a clear equation that describes the data....
2) How do I extract the coefficients? Coeffx only returns 'thinplateinterp'.
x=[0,0,0,0.5,0.5,0.5,1,1,1];
y=[0.001,0.1,10,0.001,0.1,10,0.001,0.1,10];
z=[4.35,1.37,2.31,7.04,3.58,4.14,2.08,2.35,2.43];
ylog=log10(y);
[xData, yData, zData] = prepareSurfaceData( x, ylog, z );
ft = 'thinplateinterp';
[fitresult, gof] = fit( [xData, yData], zData, ft, 'Normalize', 'on' );
Coeffx=coeffvalues(fitresult);
Accepted Answer
More Answers (1)
This is a common problem people have with splines in any form. They hope to see some nice simple function they can write down. Maybe put the function into a paper, or use in some way they would use other functional forms.
Sorry. That is pretty much never the case. Splines are great things for some purposes. But if you want to write down that nice looking function, it won't happen.
You can evaluate the function at any point. There are methods provided for that purpose. But if you really need the pretty function you can write down, you will need to use other tools.
x=[0,0,0,0.5,0.5,0.5,1,1,1];
y=[0.001,0.1,10,0.001,0.1,10,0.001,0.1,10];
z=[4.35,1.37,2.31,7.04,3.58,4.14,2.08,2.35,2.43];
ylog=log10(y);
surf(reshape(x,3,3),reshape(ylog,3,3),reshape(z,3,3))
Anyway, using a thin plate spline for such minimal data is probably wild overkill. At best, a simple polynomial model may be sufficient, and about as good as you can do with such limited data.
mdl = fit([x',ylog'],z','poly22')
This gives you a nice model you can write down. Not a very good model, but your data is highly limited.
[mdl(x,ylog);z]
As you can see, the model does predict the data reasonably well.
[xint,yint] = meshgrid(linspace(0,1),linspace(-3,1));
surf(xint,yint,mdl(xint,yint))
hold on
plot3(x,ylog,z,'ro')
You can even plot it as a nice smooth, well behaved surface.
2 Comments
Pelajar UM
on 1 Feb 2023
William Rose
on 1 Feb 2023
@Pelajar UM, your question is a reasonable one, and I don't know the answer to where the coefficients can be found. I demonstrated with tpaps() how to find 12 coefficients. This is only half the number of coefficients expected, according to the wikipedia article on thin plate splines. I also demonstrated three ways you can use a spline fit to predict values at other points:
fitresult(.5,-3)
evaluate(Coeffx,.5,-3) %works if the fit is done with normalize off
fnval(st,[.5,-3]) %st is obtained with tpaps()
Categories
Find more on Interpolation in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!



