How to get the values of biharmonic interpolation - 3D surface fitting

25 views (last 30 days)
Hi there,
I used the 'biharmonicinterp' method for 3D surface fitting and got the following surface based on 4 given data points (blue dots), which was more reasonable than other fitting method.
However, it is hard to get the interpolation values between these points. For example, I would like to slice the surface and figure put the z value change along a certain axis, but could not get the previous interpolated values. I try to use other cfit methods, but the cross section is not consistent with the 3D surface.
Could you help me to get the interpolated values by using 'biharmonicinterp' method? Or directly slice the fitted 3D surface to obtain the z value change? Thank you very much.
The code is attached below:
% Data
xData = [0;85;0;-85];
yData = [85;0;-85;0];
zData = [0.5695;0.1766;-0.2984;-0.0129];
% Set up fittype and options.
ft = 'biharmonicinterp';
% Fit model to data.
[fitresult, gof, output] = fit( [xData, yData], zData, ft, 'Normalize', 'on' );
% Plot fit with data.
figure(1)
h = plot( fitresult, [xData, yData], zData );
legend('off')
grid on
colormap(jet)
shading interp
colorbar
% Label axes
xlabel( 'X', 'Interpreter', 'none' );
ylabel( 'Y', 'Interpreter', 'none' );
zlabel( 'Z', 'Interpreter', 'none' );
% Tick label
xticks(-80:20:80)
yticks(-80:20:80)
% Paper position
set(gcf,'PaperPositionMode','auto');
  7 Comments
John D'Errico
John D'Errico on 20 Jun 2020
I had seriously thought of suggesting a polar coordinate transformation, which might have also worked reasonably, at least at first glance. I did not because it seemed to be a confusing solution. That is, convert a problem that is alreadty defined in terms of angles, into a problem where we introduce another angle due to the polar coordinate system. It just seems like something I did not want to do, not when a simpler solution was available.
However, since you brought it up, yes, I might as well discuss what happens if we do. That is, convert the region of interest into a polar coordinate problem. Now you would tranform the (x,y) plane into an (r,theta) domain. But here we see a problem suddenly arises. We have 4 data points, all of which lie at one radius.
[theta,r] = cart2pol(xData,yData);
[theta,r]
ans =
1.5707963267949 85
0 85
-1.5707963267949 85
3.14159265358979 85
So, we have 4 data points now, ALL of which lie st the same radius from the origin. They are all on a circle. So we have a function, where you might decide to interpolate circularly, around the perimeter of that circle. But now inferring what happens for smaller radii inside that circle is far more difficult.
Yes, you could make up some value at r==0. But if you knew that point, you should have provided it in the first place. You cannot use interpolation to decide what value should happen at the center of the circle, and then fit a model to that. This is far too mathematically incestuous, far too dangerous a thing to do.
And since the simple coordinate rotation provides such a good solution, just use that. And of course, I know that I hound people about this, but getting more data, IF you could actually get the data from some experimentation would always be a very good thing, greatly improving the predictive behavior of any model.
Hao Shi
Hao Shi on 20 Jun 2020
I see, I will try to get more data from additional positions, thank you very much John!

Sign in to comment.

Accepted Answer

John D'Errico
John D'Errico on 13 Jun 2020
Edited: John D'Errico on 13 Jun 2020
I don't see the problem. However, I would note that you have only 4 points, so the surface is pretty difficult to create in an intelligent way. And the use of any interpolation across the center of a domain like this can produce some interesting interpolation artifacts, if you know exactly where to look. (Having worked with interpolation in multiple dimensions for many years, I can attest to that as fact.) Anyway, what you did seems to produce something that I fully expect.
For example, how would I get a slice through that region? For eample, fix x at zero, then vary y?
[xData,yData,zData]
ans =
0 85 0.5695
85 0 0.1766
0 -85 -0.2984
-85 0 -0.0129
So my expectation would have z varying from -0.2984 to 0.5695. The shape of that curve along this path will probably be something smooth, but it will have some shape. Not necesarily just a straight line.
xint = zeros(1,50);
yint = linspace(-85,85,50);
zint = fitresult(xint,yint);
plot(yint,zint,'b')
So not at all unreasonable. Consistent with the limited data at the endpoints. Now, without copying all of the code you wrote, I'll add these last two lines to your code.
hold on
H = plot3(xint,yint,zint,'ko');
I fail to see the problem. I see a line with a lot of black o's that follows the shape of the surface you created, from corner to corner of that region. Now, where do you see a problem in what I did? I don't. The curve looks eminently reasonable, and is consistent with the plotted surface. Did you expect a straight line connecting those two end points?

More Answers (1)

darova
darova on 13 Jun 2020
  • re-create surface manually
  • Use interp2
[x1,y1] = meshgrid(-50:5:50);
z1 = fitresult(x1,y1);
xx = linspace(-50,50);
yy = 2*xx;
zz = interp2(x1,y1,z1,xx,yy);
surf(x1,y1,z1)
line(xx,yy,zz,'linew',3)

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!