equate the parameters of two equations in symbolic
2 ビュー (過去 30 日間)
古いコメントを表示
Hello,
I have two equations, one with known parameters and one with unknown. I would like to ask for a simple way to solve the system that equates the parameters for the two equations
e.g.
eq. 1 = (a2 - a1 - a3 + 1)*x1 + (2*a1 - a2 - 3)*x2 + (3 - a1)*x3
eq. 2 = 0.957*x1 - 0.253*x2 + 0.119*x3
Of course in this simple case it is easy to see that a1=2.043, a2=1.339 and a3=0.177.
One manual way that I have found to work is to create two sym vectors that v1 and v2 that contain the parameters of x1,x2 and x3 and then use the solve function
p=solve(y==b)
However this method solves the solution into a structure p.a1, p.a2 and p.a3 which is not convient (I would like to have it a vector) And second I have to manually create the sym vectors v1 and v2 which again is not convenient when I have to repeat the same thing for different equations of different orders.
Any ideas to work around this problem?
thank you in advance
0 件のコメント
採用された回答
Star Strider
2015 年 4 月 22 日
You can easily create the vector yourself in the format you choose from these results:
syms a1 a2 a3 x1 x2 x3
eq1 = (a2 - a1 - a3 + 1)*x1 + (2*a1 - a2 - 3)*x2 + (3 - a1)*x3;
eq2 = 0.957*x1 - 0.253*x2 + 0.119*x3;
[C1,T] = coeffs(eq1, [x1, x2, x3]);
[C2,T] = coeffs(eq2, [x1, x2, x3]);
[a1, a2, a3] = solve(C1 == C2, [a1, a2, a3])
producing:
a1 =
2881/1000
a2 =
603/200
a3 =
177/1000
0 件のコメント
その他の回答 (1 件)
参考
カテゴリ
Help Center および File Exchange で Symbolic Math Toolbox についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!