Is there a bug in the INTERP2 function within MATLAB 6.5 (R13) when using the "*" methods?
1 次查看(过去 30 天)
显示 更早的评论
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.
采纳的回答
MathWorks Support Team
2009-6-27
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')
0 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Startup and Shutdown 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!