Interpolation of 2D matrix using Interp2 to eliminate NaN
Show older comments
I have a 310*400 matrix, that contain NAN values. I will like to interpolate the data to eliminate the NAN. After applying this code, I observed that the NAN is still retained. A sample of my code is here.
load('km100.dat'); % load the z column data
[x,y] = ndgrid(310,400); % arrange the data into grid
data_nan=reshape(km100,[],400); %
row_vect = 1:310; %
col_vect = 1:400; %
[X,Y] = meshgrid(col_vect, row_vect);
[Xq,Yq] = meshgrid((1:1:310),(1:1:400));
V = data_nan;
data_interp = interp2(X, Y, V, Xq', Yq', 'cubic');
How do I correct it? Thanks.
Accepted Answer
More Answers (0)
Categories
Find more on NaNs in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!