From: Marcus on
Hello,

I have 5 linear (very long) equations and want to transform them into a more conveniently matrix form: A*x=b.

How can I do that with Matlab? The equations are too long, to do this by hand.

Thank you for your help!
From: Marcus on
Hello,

I have 5 linear (very long) equations (with symbolic variables) and want to transform them into a more conveniently matrix form: A*x=b.

How can I do that with Matlab? The equations are too long, to do this by hand.

Thank you for your help!
From: Marcus on
Does anybody know an answer?
From: Walter Roberson on
Marcus wrote:
> Hello,
>
> I have 5 linear (very long) equations (with symbolic variables) and want
> to transform them into a more conveniently matrix form: A*x=b.
>
> How can I do that with Matlab? The equations are too long, to do this by
> hand.

Something like this:

Vars = {sym('X1'), sym('X2'), sym('X3'), sym('X4'), sym('X5')};

for K = 1:5
b[K] = - coeff(EQNS[K], Vars{K}, 0);
A[K] = coeff(EQNS[K], Vars{K}, 1);
X[K] = Vars{K};
end


This would need adjustment if you are expecting x to be a matrix instead of a
vector -- but if you wanted that, you would have to specify how you want your
basis vectors to be generated.