MATLAB: Extrapolation of 1600 points dataset

extrapolationforecastinginterpolation

Hi, I tried to use interp1 function to extrapolate a dataset consists of 1600 points (read from Excel sheet). The variable extracted the data and can plot it easily. However, the resulted plot of interpolated and extrapolated data is linear!!!!
Here is the code I used for testing:
data=xlsread('DATA.xls','A2:A1601'); x=[1:1:1600];
xi=1:1:1700;
z=interp1(x,data,xi,'spline','extrap');
plot(x,data,'or',xi,z);
All help is appreciated. Link to Excel file: http://www.mediafire.com/?8z3riofux9tz4z0

Best Answer

Neither the interpolation nor the extrapolation are linear, although I can see why you might think they are, given what you've plotted.
In the interpolated region, because you've chosen the interval of xi to be the same as x, all you are getting is the (perfect) match with your known points, and the lines are just connecting the dots, so you see line segments. If you were to choose the interval to be, say, 0.1 instead, then you would see the nonlinearity of the spline.
In the extrapolated region, you can see the nonlinearity if you zoom into the area just after the known points. It rockets north very rapidly, and looks linear after that.
Here is some code, slightly edited from yours, that illustrates these thoughts:
data=xlsread('DATA.xls','A2:A1601');
x=[1:1:1600];
xi=1:0.2:1603;
z=interp1(x,data,xi,'spline','extrap');
figure
plot(x,data,'or',xi,z);
set(gca,'XLim',[1595 1605])
I'm not sure what you were expecting, but simple extrapolation is not going to replicate the pattern in the known region. If that was what you wanted, you're going to need some kind of simulation, maybe based on the mean growth and variance of the known data.