开发者

use interp2 with vectors instead of mesh grids

I'm trying to use interp2 where my five inputs are all 1 by n vectors. 开发者_如何学PythonIs this possible? or do I need to enter them in mesh format?


No, you need to use meshgrid to generate your two first input arguments (X,Y), just like in this example (provided in Matlab's documentation):

[X,Y] = meshgrid(-3:.25:3);
Z = peaks(X,Y);
[XI,YI] = meshgrid(-3:.125:3);
ZI = interp2(X,Y,Z,XI,YI);
mesh(X,Y,Z), hold, mesh(XI,YI,ZI+15)
hold off
axis([-3 3 -3 3 -5 20])

I hope it helps.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜