Why does using the INTERP2 function with the "spline" option produce different outputs depending on the number of interpolated data points in MATLAB 7.0 (R14)?

1 view (last 30 days)
I use the "spline" option with the INTERP2 function to interpolate my data. I find that using the following two different syntaxes, INTERP2 produces different interpolated values for the same interpolation point:
interp2(X,Y, Z, [pi pi+0.01]', [0 0.1]', 'spline')
interp2(X,Y, Z, pi+0.01, 0.1, 'spline')
ans =
20.3496
-807.0517
ans =
15.9434
Notice the interpolated value at (pi+0.01, 0.1) is different depending on the number of interpolation points.

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 27 Jun 2009
This bug has been fixed in Release 2006a (R2006a). For previous product releases, read below for any possible workarounds:
We have verified that there is a bug in MATLAB 7.0 (R14) in the way that MATLAB handles the INTERP2 function using the spline method.
To work around this issue, when interpolating multiple points, specify the "x" and "y" locations of interpolation points as row and column vectors respectively, instead of as matrices. For example, the following code interpolates the data at four locations (pi, 0), (pi, 0.1), (pi+0.01, 0), (pi+0.01, 0.1):
interp2(X,Y, Z, [pi pi+0.01], [0 0.1]', 'spline');

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!