What algorithm does the scattered interpolant 'boundary' extrapolation use when it extrapolates to a convex hull?

47 次查看(过去 30 天)
The documentation within the 'boundary' extrapolation mode for the scattered interpolant states that it " [evaluates] to the value of the nearest point on the convex hull." However, if you have a non-convex domain smaller than its convex hull, then that specification seems to necessitate an initial extrapolation to approximate the function values on the convex hull that were external to the original domain. I would appreciate it if someone could provide the specific details of this algorithm for me or clarify the description if I have misunderstood something fundamental.
  4 个评论
Atharv
Atharv 2025-9-19,22:36
Since the official documentation is vague, I opened the .m file itself and found that quoted line as a comment on the 'boundary' option. As Torsten mentioned, it is also in the description of the nearest neighbor extrapolation method. From that documentation, I would then assume PCHIP is the default for the standard scatteredInterpolant object. However, since the documentaiton is actually for the curve fitting toolbox, this is all just speculation on my part.

请先登录,再进行评论。

采纳的回答

William Rose
William Rose 2025-9-20,2:12
I don't think you have misunderstood anything fundamental. The description is unclear. Here are examples to illustrate how it works. We will check each how extrapolation method "boundary" works with each of the three interpolation methods: "nearest", "linear", and "natural".
Example 1. Method=nearest, extrapolation method=boundary. In this case, it appears that the extrapolated value is the value of the nearest of the original points.
[X,Y]=meshgrid(0:4,0:3);
% Next: move corner point so data set is concave at corner
X(end)=3.3; Y(end)=2.3;
V=(X.^2+Y.^2).^0.5; % V=distance from origin
% Display X,Y points
figure; plot(X,Y,'ro','MarkerFaceColor','r')
Now examine the behavior around the top right corner of the plot above (x=3 to 5, y=2 to 4), since that is where the point set is concave.
[Xq,Yq]=meshgrid(3:.05:5,2:.05:4); % query points
% original points, near the query points (for plotting)
XL=X([15,16,19,20]); YL=Y([15,16,19,20]); VL=V([15,16,19,20]);
% Compute scattered interpolant, method=nearest, extrap.method=boundary
F1=scatteredInterpolant(X(:),Y(:),V(:),'nearest','boundary');
Vq1=F1(Xq,Yq); % interpolate and extrapolate
% Plot results
figure; surf(Xq,Yq,Vq1); colorbar; hold on; view(0,90)
plot3(XL,YL,VL,'ro','MarkerFaceColor','r')
xlabel('X'); ylabel('Y'); zlabel('Z'); title('nearest, boundary');
Careful examination of the points above suggests that the extrapolated value equals the value of the nearest original point, not the value of the nearest point on the boundary of the convex hull. For example, at Xq,Yq=4.05,3, extrapolated Vq1=4.47, which is the value of the closest original point (at X,Y=4,3). The closest point on the convex hull is at about X=3.525,Y=2.475, and this point has extrapolated value V=4.02 (by nearest neighbor). So, if Vq were using the extrapolated value at the closest point on the convex hull, Vq would be 4.02 when Xq,Yq=4.05,3. But Vq1 is not that.
Example 2: Method=linear, extrap.method=boundary.
% Compute scattered interpolant, method=linear, extrap.method=boundary
F2=scatteredInterpolant(X(:),Y(:),V(:),'linear','boundary');
Vq2=F2(Xq,Yq); % interpolate and extrapolate
% Plot results
figure; surf(Xq,Yq,Vq2); colorbar; hold on
plot3(XL,YL,VL,'ro','MarkerFaceColor','r')
xlabel('X'); ylabel('Y'); zlabel('Z'); title('linear, boundary');
Adjust the view to further appreciate and understand the plot.
In the case above, points along the convex hull boundary are intepolated linearly between the original points that are on the convex hull, ignoring original points interior to the convex hull. Points outside the convex hull are extrapolated from the convex hull boundary, and are not affected by points interior to the convex hull.
Example 3: Method=linear, extrap.method=boundary.
% Compute scattered interpolant, method=natural, extrap.method=boundary
F3=scatteredInterpolant(X(:),Y(:),V(:),'natural','boundary');
Vq3=F3(Xq,Yq); % interpolate and extrapolate
% Plot results
figure; surf(Xq,Yq,Vq3); colorbar; hold on
plot3(XL,YL,VL,'ro','MarkerFaceColor','r')
xlabel('X'); ylabel('Y'); zlabel('Z'); title('natural, boundary');
Adjust the view to understand the surface better. It looks the same as the plot when method='linear'.
This case is like the linear case: points on the convex hull boundary are intepolated linearly between the original points that are on the convex hull, ignoring original points interior to the convex hull. Points outside the convex hull are esitmated from the points on the convex hull boundary. Inside the convex hull, the esitmated values are slightly different with natural method than with the linear method, consistent with natural versus linear interpolation.
If you vary the height of the point inside the convex hull, you will see that the results with method="nearest" still work the same way. With method="linear" or "natural", the interpolated points on the convex hull boundary, and the extrapolated points outside the convex hull, are not altered by the adjustment of the nearby point inside the convex hull. Their height is determined only by the original and interpolated points along the boundary of the convex hull.
  4 个评论
Atharv
Atharv 2025-9-20,16:09
My guess for the exact method of linear extrapolation from the boundary is something like the following:
Given a set of points on the boundary, select three sequential points p1, p2, p3. Compute (p3-p1)/||p3-p1|| as the unit tangent vector, and then apply the appropriate rotation to approximate the unit normal vector. Taking a central difference along this direction gives a fair approximation for the normal derivative at p2. This would then explain the "flattening out" we see in the diagrams, as most of that gradient is "concentrated" along the tangent direction due to the sharp turns and mostly linear nature of the convex hull of this specific shape.
This hypothesis also appears to superficially match the figures shown in the documentation page: https://www.mathworks.com/help/matlab/ref/scatteredinterpolant.html
Once again, this is all just speculation, and I appreciate the detail in your examples. I am going to mark this thread resolved, as your first answer made the mechanisms of the scatteredInterpolant more clear even if we are still uncertain about the exact details, which likely only Mathworks staff know for certain. Due to the nature of my use case, I now plan to use a more transparent algorithm or implement my own. Thank you for your responses.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Discrete Data Plots 的更多信息

产品


版本

R2025a

Community Treasure Hunt

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

Start Hunting!

Translated by