0
我们给出了n×n个数据。近似的功能。例如, 。如果我们给出2(1,1),3(1,2),4(2,1),5(2,2) 那么我们必须插入2 D-ultinomial作为$ 0 * x * y + y + 2 * X-1 $。MATLAB。我们如何通过插值得到2d多项式
我们给出了n×n个数据。近似的功能。例如, 。如果我们给出2(1,1),3(1,2),4(2,1),5(2,2) 那么我们必须插入2 D-ultinomial作为$ 0 * x * y + y + 2 * X-1 $。MATLAB。我们如何通过插值得到2d多项式
这个问题可以表示为一组线性方程组,这些方程组使用mldivide函数来解决这些问题是微不足道的。
让我用你包含的例子来说明这一点。
% from the given example
in = [...
1,1;
1,2;
2,1;
2,2];
out = [...
2;
3;
4;
5];
% compute the variable terms in the polynomial
x = in(:,1);
y = in(:,2);
xy = x .* y;
c = ones(size(out)); % constant
% compute the coefficients of the polynomial
p = [xy,y,x,c] \ out;
% result: [0; 1; 2; -1]
声明p = [xy,y,x,c] \ out
计算时问题过约束的最佳系数(最小平方误差)(即没有解到恰好满足所有方程)。但是如果只有与变量一样多的方程(如本例中由于有4个输入 - 输出对有4个方程,并且有4个系数需要估计),那么系数可以简单地通过p = inv([xy,y,x,c]) * out
。