Problem in using scatteredInterpolant
1 次查看(过去 30 天)
显示 更早的评论
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 个评论
Walter Roberson
2021-10-4
Nothing can be done for that purpose. If you need integers then you should not be doing any kind of interpolation.
采纳的回答
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!