Как мне написать функцию, имеющую 3 входа (2 вектора, состоящие из коэффициентов [abc] и вектора значений x) из двух линейных уравнений формы ax + by = c, которая выводит вектор, дающий значения 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