MATLAB Answers

How can I interpolate data with the function ScatteredInterpolant (or else) within the boundaries of the input data only?

2 views (last 30 days)
NP
NP on 16 Sep 2019
Commented: Star Strider on 17 Sep 2019
Hi,
I'm testing interpolation functions to create grid data (Data Terrain Model) from contour lines stored in an xyz file that I imported in the structure contour_grid:
[xi,yi] = meshgrid(Xmin:res:Xmax, Ymin:res:Ymax);
f = scatteredInterpolant(contour_grid.X,contour_grid.Y,contour_grid.Z);
f.Method = 'natural';
zi= f(xi,yi);
My problem is that the ScatteredInterpolant function struggles to output sensible values outside of the contour lines. It makes sense since it does not have enough points to interpolate properly/sensibly. See "lip" below":
I would like to find a way not to output any data outside of the area defined by my outermost contour line or alternatively to automatically crop the grid domain accordingly (keep anything wth x >1.835 x 10^6 for example in that case).
I can't see how the function can be asked to do that. I'm trying to use indices to discard the erroneous data but I cannot formulate it properly.
Can anyone think of a smart way to do that/ has already solved this kind of issue?
Thank you,

  0 Comments

Sign in to comment.

Accepted Answer

Star Strider
Star Strider on 16 Sep 2019
Specify 'ExtrapolationMethod' as 'none'.

  4 Comments

Show 1 older comment
Star Strider
Star Strider on 17 Sep 2019
As always, my pleasure!
MATLAB functions are extremely versatile, and have significant options. I had to search for it in the documentation.
NP
NP on 17 Sep 2019
Not all pages refering to scaterredInterpolant seem to mention that parameter. Always worth browsing some more!

Sign in to comment.

More Answers (0)

Sign in to answer this question.