MATLAB: How to interpolate the NaNs in the middle part of a curve extrapolationinterpolation Hi everyone, I am wondering how to interpolate the NaNs in the middle part of a curve? Like the plot below: x=1:200; Can anyone offer a hint? And besides, how to do extrapolation in matlab? Thanks a lot! Best Answer e.g.a = 1:20;b = rand(1,20);b(4:7) = NaN;newB = interp1( a( ~isnan(b) ), b( ~isnan(b) ), a );also includes an extrapolation argument that you can read about on the help page:doc interp1 Related SolutionsMATLAB: Fill missing NaN values with Interpolation a = rand(100,1) ;% put some NaN'sa(randsample(100,20)) = NaN ;%%interpolate x = 1:length(a) ;a(isnan(a)) = interp1(x(~isnan(a)),a(~isnan(a)),x(isnan(a))) ;plot(x,a,'.r') hold onplot(x,a,'b') MATLAB: Correlation between two row matrices Like that, each value of "a" is correlated to each value of "b", but applying the formula of the correlation, the correlation of two single numbers is NaN. To compute the correlation correctly, traspose the input vectorsresult = corr(a', b'); Related QuestionHow to make the spline function only smooth existing data points and not smooth over NaNsHow to use the index ? how to drop elements from a matrixInterpolation method (spline)Does a cell vector contains only NaN
Best Answer