Is there a bug in the INTERP2 function within MATLAB 6.5 (R13) when using the "*" methods?

1 view (last 30 days)
The documentation states that for "ZI = interp2(X,Y,Z,XI,YI, method) ", "you can pass in the row and column vectors XI and XI, respectively. In this case, interp2 interprets these vectors as if you issued the command meshgrid(XI,YI)." However, this is not the case when the method is prepending with an "*". To view an example of this, generate the following data:
load census
[xg yg]=meshgrid(cdate,pop);
xi = 1800:20:2000; yi = [1:30]';
zg = rand(21,21);
Then, the following command executes correctly as stated in the documentation:
interp2(xg,yg,zg,xi,yi,'nearest')
However, when the method is changed to "*nearest"
interp2(xg,yg,zg,xi,yi,'*nearest')
I receive an error message.
??? Error using ==> interp2 (nearest)
XI and YI must be the same size.

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:
This bug has been fixed in MATLAB 7.0 (R14). If you are using a previous version, see the following information.
This is a bug in the INTERP2 function within MATLAB (6.5) R13.
Currently, to work around this issue, you must use the MESHGRID command prior to calling INTERP2 when using a method with the "*" indicator.
[xi yi] = meshgrid(xi,yi);
interp2(xg,yg,zg,xi,yi,'*nearest')

More Answers (0)

Categories

Find more on Startup and Shutdown in Help Center and File Exchange

Products


Release

R13SP1

Community Treasure Hunt

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

Start Hunting!