MATLAB Answers

Extrapolation of 1600 points dataset

14 views (last 30 days)
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

  0 Comments

Sign in to comment.

Accepted Answer

the cyclist
the cyclist on 25 Jun 2011
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.

  2 Comments

Waleed El-Badry
Waleed El-Badry on 26 Jun 2011
Thanks for your response. You are quite correct as I seeked the extrapolation to follow the signal pattern. Appearently extrapolation was not the proper solution to follow. Do you suggest using ARMA or Neural Network for forecasting?
the cyclist
the cyclist on 26 Jun 2011
ARMA is certainly commonly used. I don't know much about NN for this sort of thing.
Also, it would be good for you to "accept" my answer since you found it helpful, so that others seeking similar solutions will find it more easily.

Sign in to comment.

More Answers (0)

Sign in to answer this question.