Follow

clear;

// *** 補間元データ ***
n = 8;
m = 10;
x = linspace(0, 2 * %pi, n);
y = linspace(0, 2 * %pi, m);
z = 2 * sin(x') * sin(y);

// *** 補間 ***
xx = linspace(0, 2 * %pi, 40);
yy = linspace(0, 2 * %pi, 40);
[xp,yp] = ndgrid(xx, yy);
zp = linear_interpn(xp, yp, x, y, z);

// *** グラフの描画 ***
plot3d(xx, yy, zp, flag=[2 6 4]);
[xg, yg] = ndgrid(x, y);
param3d1(xg, yg, list(z, -9*ones(1, m)), flag=[0 0]);
xtitle("Bilinear interpolation of 2sin(x)sin(y)");
legends("interpolation points",-9,1);