Problem in using scatteredInterpolant

Hi,
I am doing interpolation here to get values from variable z according to the respective lat lon. My variables from hdf file are:
lat = 406x270;
lon = 406x270;
z = 2030x1354;
lat_i = imresize(lat,[2030 1354],'bilinear');
lon_i = imresize(lon,[2030 1354],'bilinear');
There's another text file that contains lat lon values in the form of column vector:
lat_txt = tab.lat; % extract the column of latitude values from text file (3798x1 double)
lon_txt = tab.lon; % extract the column of longitude values from text file (3798x1 double)
I've used scatteredInterpolant here for interpolation
F = scatteredInterpolant(lat_i(:), lon_i(:), z(:));
Res = F(lat_txt, lon_txt); % To get values of z according to the lat lon of text file
Problem is z conatin integers (0,1,2,3,4) and using scatteredInterpolant gives values (1, 1.838, 2.84, 2.139, 2, 2.0022, 1.0014, 3.339, 3.000, 2.779,3 etc). And this thing is effecting my results. Is there a way that I only get in the form of integers (0,1,2,3,4)?
Warning:
Warning: Duplicate data points have been detected and removed - corresponding values have been averaged.
Secondly, I want 0 and 1 to be removed from z before passing it through scatteredInterpolant. I assign NaN to pixels containing 0 and 1. Not sure whether it's fine or not. Any help will be highly appreciated.

3 个评论

Problem is z conatin integers (0,1,2,3,4) and using scatteredInterpolant gives values (1, 1.838, 2.84, 2.139, 2, 2.0022, 1.0014, 3.339, 3.000, 2.779,3 etc). And this thing is effecting my results. Is there a way that I only get in the form of integers (0,1,2,3,4)?
No
@Walter Roberson what can possibly be done to avoid getting such values (1, 1.838, 2.84, 2.139, 2, 2.0022, 1.0014, 3.339, 3.000, 2.779,3). Any other function in MATLAB other than scatteredInterpolant?
Nothing can be done for that purpose. If you need integers then you should not be doing any kind of interpolation.

请先登录,再进行评论。

 采纳的回答

更多回答(0 个)

类别

帮助中心File Exchange 中查找有关 Interpolation of 2-D Selections in 3-D Grids 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by