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?
댓글 수: 2
madhan ravi
2019년 3월 4일
"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
채택된 답변
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!