I used the following code to perform an interpolation of my matrix , but instead of solving the problem of NaNs entries I have got more because my matrix has got 2 or 3 successive columns of NaNs. Now my question is how to get rid of the NaN s in my matrix without losing data which was available before the interpolation?
[rr,cc] = size(MT);xi = 1:cc;% columns
idx = ~isnan(MT);for r = 1:rr MTNew(r,:) = interp1(xi(idx(r,:)),MT(r,idx(r,:)),xi,'linear','extrap');end
Thank you !
Best Answer