MATLAB: Do I receive an error when I use the INTERP2 function with 4 inputs in MATLAB 7.0 (R14)

4extrapolationextrapvalinputsinterp2interpolationMATLABundefined

I receive an error when I call INTERP2 with 4 inputs as shown below:
Z = rand(10,10);
x = 12; y = 5;
interp2(Z,x,y,'*linear')
Note that the values of "x" and "y" cause the function to extrapolate. The error occurs only when extrapolating. The following error occurs:
??? Input argument "ExtrapVal" is undefined.
Error in ==> interp2>nearest at 584
if any(vout(:)), F(vout) = ExtrapVal; end
Error in ==> interp2 at 98
zi = nearest(varargin{1:end-index}, ExtrapVal);

Best Answer

This bug has been fixed in Release 14 Service Pack 3 (R14SP3). For previous product releases, read below for any possible workarounds:
We have verified that there is a bug in MATLAB 7.0 (R14) that affects the way the INTERP2 function handles 4 inputs. To work around this issue, use the following syntax when calling the INTERP2 function:
Z = rand(10,10);
x = 12; y = 5;
[m,n] = size(Z);
interp2(1:m,1:n,Z,x,y,'*linear')