scatteredInterpolant with extrapolation method set to none doesn't give NaN results

6 views (last 30 days)
Why does the "scatteredInterpolant" function give results outside the domain even when the extrapolation method is set to none? Shouldn't it be NaN if it isn't extrapolating?

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 20 Dec 2017
An extrapolation method of none means "Any queries outside the convex hull of Points return NaN."
It is possible that the point being provided is outside the domain but still within the convex hull.
There is currently no way to use "scatteredInterpolant" with a more defined a boundary.
Workaround:
Take the output of the "scatteredInterpolant" and put it through an if statement that checks if it is within the boundary. A good way to get a more defined boundary is to use the "boundary" function.
 
>> F = scatteredInterpolant(xdata, ydata, vals,'natural','none');
>> DT = delaunayTriangulation(xdata, ydata);
>> b = boundary(xdata, ydata);
>> out = F(x, y);
>> if ~inpolygon(x, y, DT.Points(b,1),DT.Points(b,2))
>> out = NaN;
>> end
This sets "out" to be NaN when it is outside the boundary, even if it is inside the convex hull
A more detailed example can be found inside the attached file.

More Answers (0)

Categories

Find more on Creating and Concatenating Matrices in Help Center and File Exchange

Tags

No tags entered yet.

Products


Release

R2016b

Community Treasure Hunt

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

Start Hunting!