2017-01-23 4 views

答えて

0

この問題は、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問題がoverconstrainedれる最適係数(最小二乗誤差)(すなわち解が正確すべての方程式を満たすに存在していない)を算出します。しかし、変数があるだけの数式があれば(この例のように、4つの入出力ペアのため4つの式があり、推定する必要のある4つの係数がある)、係数は簡単にp = inv([xy,y,x,c]) * outで計算できます。

関連する問題