0
ax + +の2つの線方程式の3つの入力(係数のベクトル[abc]とxの値からなる2つのベクトル)を持つ関数を書くにはどうすればよいですか? = cは、交点のxとyの値を与えるベクトルを出力します。Matlab:交点のxとyの値を与える出力ベクトル
例:solveSystem([1 -1 -1]、[3 1 9]、 - 5:5)これまで
[2 3]を生成しなければならない:
function coeff=fitPoly(mat)
% this function takes as an input an nx2 matrix consisting of the
% coordinates of n points in the xy-plane and give as an output the unique
% polynomial (of degree <= n-1) passing through those points.
[n,m]=size(mat); % n=the number of rows=the number of points
% build the matrix C
if m~=2
fprintf('Error: incorrect input');
coeff=0;
else
C=mat(:,2); % c is the vector of y-coordinates which is the 2nd column of mat
% build the matrix A
for i=1:n
for j=1:n
A(i,j)=(mat(i,1))^(n-j);
end
end
coeff=inv(A)*C;
end
ようになっています。あなたはax + bu = cを意味しましたか? – Kavka
申し訳ありません...意味ax + by = c –
あなたの質問とあなたが投稿したコードは一貫していません。線の交点または多項式の近似を探していますか?あなたはあなたの質問を明確にすべきです。 – Kavka