Does Matlab interp2 (Spline) OverEstimates/buggy?!

3 views (last 30 days)
Hi All, I used Spline method in interp2 function to extrapolate some points beyond my given mesh grid range. the mesh grid is shown below:
on X-Z plane, it looks like this:
on Y-Z plane, it looks like this:
When i extrapolate using command:
Z2=interp2(X,Y,Z,231,3888,'spline')
Z2 =
855.0972
From the graph and by common sense , there is no way that Z will be 855...
i used a free Excel add-on function called interp3d, it gives me 255.3 which seems much more reasonable than Matlab. Its frustrating to see a free add-on of Excel gives better solution here, not mentioning that its also much easier to use too.
Did I do anything wrong or there are bugs in the spline method? Please Help... Thanks
-Bill
  3 Comments
Bill Zhao
Bill Zhao on 6 Feb 2014
Went on did a whole series of tests; this time, Xi kept constant[227:0.1:228.5], while Yi is changing from 10 to 3000 This resulted plots on X-Z plane shown as below:
The given range of mesh on Y axis is 300 to 2400. It is now clear that when Yi is out of this range, its doing something not expected. it does not extrapolate itself (i.e. it stopped moving up and down on X-Z plan)...
-Bill
Bill Zhao
Bill Zhao on 6 Feb 2014
i have used interp1 and extended the given Y of the mesh to 5000 using linear interpolation:
Hopefully this will work?...
-B

Sign in to comment.

Accepted Answer

John D'Errico
John D'Errico on 6 Feb 2014
Edited: John D'Errico on 6 Feb 2014
Extrapolation using a spline is insane. Period. You get what you deserve, i.e., a virtually random result. In fact, any extrapolation tends to be dangerous, unless you use a viable model that makes physical sense. So polynomials are also useless.
You can use my own gridfit tool (found on the File Exchange) to extrapolate, as at least it tends to extrapolate as smoothly and linearly as possible. Even so, extrapolate too far and you will get what Mark Twain said...
"In the space of one hundred and seventy-six years the Lower Mississippi has shortened itself two hundred and forty-two miles. This is an average of a trifle over one mile and a third per year. Therefore, any calm person, who is not blind or idiotic, can see that in the Old Oolitic Silurian Period, just a million years ago next November, the Lower Mississippi River was upward of one million three hundred thousand miles long, and stuck out over the Gulf of Mexico like a fishing-rod. And by the same token any person can see that seven hundred and forty-two years from now the Lower Mississippi will be only a mile and three-quarters long, and Cairo and New Orleans will have joined their streets together, and be plodding comfortably along under a single mayor and a mutual board of aldermen. There is something fascinating about science. One gets such wholesale returns of conjecture out of such a trifling investment of fact."
Mark Twain, Life on the Mississippi (1883)
So, what happens when you try to extrapolate using splines which are essentially polynomials, carved into segments? Think of what a cubic polynomial does as it goes to infinity. It swoops up (or down) with great alacrity. (Hmm, I think I'm starting to sound like Mark Twain himself.) And the shape of that swoop will depend on subtle variations of the data along the edges. It will also depend on subtle variations in the code, on exactly how the spline was implemented. So trusting a spline extrapolant is, as I said, simply insane.
In fact, trusting any extrapolant is a dangerous thing to do. You can put more faith in models used for extrapolation that are based on intelligently chosen physical principles. But even then, extrapolation too far is a dangerous thing to do. Sorry, but it just is. Just remember what Mark said.
  1 Comment
Bill Zhao
Bill Zhao on 18 Feb 2014
Tried your gridfit function, worked very well.
Thanks for sharing

Sign in to comment.

More Answers (0)

Categories

Find more on Interpolation in Help Center and File Exchange

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!