开发者

use interp2 with vectors instead of mesh grids

开发者 https://www.devze.com 2023-01-20 04:09 出处:网络
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

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

精彩评论

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

关注公众号