I am assuming that you want the equations to be equal to 0, and that no equals sign appears in the equations.
Parse the expressions to find the coefficients - put into a matrix (A).
I am using here a near trick that assumes that the variables are always x1, x2, etc. Also you must write the * sign for multiplications. The FindCoeffs function finds the coefficients by assigning ones and zeros to the variables.
Then, you can solve the equations using linsolve.
function FindEquations()
a = { x1+x2 - 6 , x1 - x2 - 2 };
A = [];
B = [];
for i=1:numel(a)
[b,l] = FindCoeefs(a{i}, numel(a));
A(end+1,:) = l;
B(end+1) = -b;
end
linsolve(A,transpose(B))
end
function [b,p] = FindCoeefs(expr, n)
for j=1:n
eval(sprintf( x%d=0; ,j));
end
b = eval([expr ; ]);
p = zeros(1,n);
for i=1:n
for j=1:n
eval(sprintf( x%d=0; ,j));
end
eval(sprintf( x%d=1; ,i));
p(i) = eval([expr ; ]) - b;
end
end