MATLAB: How to interpolate nx2 (x,y) matrix include some NaNs with newton’s interpolation.

interpolataionMATLABnewton interpolataionnewton's interpolataion

% data1 is loaded data, nx2 matrix
x1 = data1(:,1); % constant time interval, nx1 matrix
y1 = data1(:,2); % data about x, nx1 matrix
x1, y1 is like
x1 = [ 0 5 10 15 20 25 30 35 40 45. . . ]
y1 = [ 0 0 2 3 NaN 11 14 17 NaN 13 . . . ]
how can i interpolate data1 to idata1 with newton's interpolataion (or other interpolation without using interp1).
idata1 is nx2 matrix with all NaNs are replaced by interpolation result.

Best Answer

Since all points in x1 are equidistant, therefore, it is not really relevant in the interpolation. You can use fillmissing(): https://www.mathworks.com/help/releases/R2020a/matlab/ref/fillmissing.html to replace the NaN values. It gives several different options to replace the missing values.