MATLAB: How to get the values of biharmonic interpolation – 3D surface fitting

'biharmonicinterp' interpolation3d surface fitting3d surface slice

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

Best Answer

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?