You can use MATLAB's built-in function interp1 to perform 1-D interpolation of data. You'll need to first identify the NaN values in price1 using the isnan function:
main.m256 chars12 lines
Output:
main.m57 chars2 lines
In the interp1 function, we pass the following arguments:
time(~nanInd): non-NaN time valuesprice1(~nanInd): non-NaN price valuestime(nanInd): time values where NaN occurred and we want to interpolate pricegistlibby LogSnag