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.
Best Answer