Is there a way to specify independent variables when solving symbolic equations?

11 次查看(过去 30 天)
Lets say I have a set of X equations with Y>X symbolic variables defining relations between several dependent and independent variables:
syms a b c d e
eq1 = a + 3*c == b*2 - 5*e - d;
eq2 = b - 2*a == e;
eq3 = d - 2*b == 10*a - e;
I want to be able to solve for a in terms of b,c,d; hence eliminating e from these equations.
When I do:
solve(eq1,eq2,eq3)
It returns:
struct with fields:
c: [1×1 sym]
d: [1×1 sym]
e: [1×1 sym]
I have tried:
solve(eq1,eq2,eq3,a)
But it gives an empty symbol:
Empty sym: 0-by-1
But from the equations above, it is clear that a could be described solely in terms of b,c,d.
I want the result of this to be:
a = M*b + N*c + P*d
Is there a way to do this in Matlab?

采纳的回答

Walter Roberson
Walter Roberson 2019-3-4
Except for some cases involving inequalities, you need to solve for the same number of variables as you have equations. And the inequalities case fails a lot of the time anyhow.
You are trying to solve three equations for 1 variable. You cannot do that.
What you can do is
sol = solve( subs([eq1, eq2], e, solve(eq3,e)), [a b])
This will give you sol.a and sol.b in terms of c and d

更多回答(0 个)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by