I have an extreme sparse set of lat-lon scattered data and I need to estimate values in a regular grid. I would like to avoid to have interpolated values when I am far from data (for a given threshold), and rather having NaN in this case. Is there any practical option for doing this?
Here is an example (messy!) code:
% a. dummy scattered data (two clouds);
x=[rand(1,11).*100, rand(1,11).*100+400];y=[rand(1,11).*100, rand(1,11).*100+400];z=rand(1,22).*100;scatter(x,y,30,z); colorbar; % plot
% b. interpolation
F=TriScatteredInterp(x',y',z'); % interpolant (I know I should not use TriScatteredInterp anymore..)
[xi,yi]=meshgrid([0:10:500],[0:10:500]);% values for regular grid
zi=F(xi,yi);% extract on my regular grid
%
figure(), surface(xi,yi,zi); % plot interpolated value
What I want is that not only in the convex hull, but also if no data are found within a given distance are set to NaN. it is a sort of clustering, I guess… is there any easy option or interpolation trick to do this? Any help is appreciated! thank you.
Best Answer