Clear Filters
Clear Filters

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

20 views (last 30 days)
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?
  2 Comments
madhan ravi
madhan ravi on 4 Mar 2019
"I want to be able to solve for a in terms of b,c,d; hence eliminating e from these equations."
please explicitly state how your result should look like

Sign in to comment.

Accepted Answer

Walter Roberson
Walter Roberson on 4 Mar 2019
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

More Answers (0)

Community Treasure Hunt

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

Start Hunting!