MATLAB: Missing data values with interpolation

interpolationnan

Hello everybody,
I have a cell array each containing a sequence of diferent values. The sequences contains some missing values (I've represented with NaN). I would like to replace all this NaN places with numbers. I think the better way is do an interpolation but I don't know how to code this Nan and how to save it on a table in Matlab.
I1= interp1(x,y,'linear');
Greetings,
Pd) I've tried this but it doesn't work
nanData = isnan(y);
index = 1:numel(y);
data2 = y;
data2(nanData) = interp1(index(~nanData), y(~nanData), index(nanData));

Best Answer

x={ 1 2 3 4 5 6 7 8 9 10}
y={ 0.3850 NaN 3.0394 NaN 0.6475 1.0000 1.5000 NaN 1.1506 0.58}
x=cell2mat(x);y=cell2mat(y);
xi=x(find(~isnan(y)));yi=y(find(~isnan(y)))
result=interp1(xi,yi,x,'linear')