我有一个数组[160,160],有27个测量数据点,想要插入整个数组。我找到了以下代码,但是没有得到它必须移交哪些参数,以便此方法有效:
public static double BilinearInterpolation(double[] x, double[] y, double[,] z, double xval, double yval)
{
//calculates single point bilinear interpolation
double zval = 0.0;
for (int i = 0; i < x.Length - 1; i++)
{
for (int j = 0; j < y.Length - 1; j++)
{
if(xval>=x[i] && xval<x[i+1] && yval>=y[j] && yval<y[j+1])
{
zval = z[i,j]*(x[i+1]-xval)*(y[j+1]-yval)/(x[i+1]-x[i])/(y[j+1]-y[j])+
z[i+1,j]*(xval-x[i])*(y[j+1]-yval)/(x[i+1]-x[i])/(y[j+1]-y[j])+
z[i,j+1]*(x[i+1]-xval)*(yval-y[j])/(x[i+1]-x[i])/(y[j+1]-y[j])+
z[i+1,j+1]*(xval-x[i])*(yval-y[j])/(x[i+1]-x[i])/(y[j+1]-y[j]);
}
}
}
return zval;
}
public static double[] BilinearInterpolation(double [] x, double[] y, double[,]z,double[] xvals, double[]yvals)
{
//calculates multiple point bilinear interpolation
double[] zvals = new double[xvals.Length];
for (int i = 0; i < xvals.Length; i++)
zvals[i] = BilinearInterpolation(x, y, z, xvals[i], yvals[i]);
return zvals;
}
double [] x - &gt;我的点在数组中的x坐标?
double [] y - &gt;我的点在数组中的y坐标?
double [,] z - &gt;一个数组,其中存储插值?
double xval - &gt; ??
double yval - &gt; ??
这是对的吗?或者你可以更容易地插入数组双线性。
答案 0 :(得分:0)
我认为xval
和yval
是您要插入的值。这些是您要评估的点的坐标。